Skip to content

Instantly share code, notes, and snippets.

@LS80
Created March 28, 2016 21:10
Show Gist options
  • Save LS80/b5129fac18edb4fe8897 to your computer and use it in GitHub Desktop.
Save LS80/b5129fac18edb4fe8897 to your computer and use it in GitHub Desktop.
Create Network Manager OpenVPN certificates and keys from .ovpn file
FILE_NAMES = {'ca' => 'ca.crt',
'cert' => 'usr.crt',
'key' => 'usr.key',
'tls-auth' => 'tls.key',
}
config = File.read(ARGV[0])
FILE_NAMES.each do |tag, filename|
config.match(/<#{tag}>(.*?)<\/#{tag}>/m)
File.open(filename, 'w') {|f| f.write($1)} if $1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment