Skip to content

Instantly share code, notes, and snippets.

@LS80
Last active March 29, 2016 14:35
Show Gist options
  • Save LS80/bb12a60816d2179dd6fc to your computer and use it in GitHub Desktop.
Save LS80/bb12a60816d2179dd6fc to your computer and use it in GitHub Desktop.
Create Network Manager OpenVPN certificates and keys from .ovpn file
import sys
import re
FILE_NAMES = {'ca': 'ca.crt',
'cert': 'usr.crt',
'key': 'usr.key',
'tls-auth': 'tls.key',
}
config = open(sys.argv[1]).read()
for tag, filename in FILE_NAMES.iteritems():
m = re.search("<{0}>(.*?)<\/{0}>".format(tag), config, re.M|re.S)
if m:
with open(filename, 'w') as f:
f.write(m.group(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment