Last active
March 29, 2016 14:35
-
-
Save LS80/bb12a60816d2179dd6fc to your computer and use it in GitHub Desktop.
Create Network Manager OpenVPN certificates and keys from .ovpn file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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