Have an OpenVPN config file with inline certificates that you need to split up because the Ubuntu team haven't fixed that 2+ year old bug in Network Manger?
You've come to the right place!
This script will split the file out into it's respective certs/keys and output a replacement .ovpn
file with cert/key paths.
First of all make yourself a secure home folder for you VPN suff:
mkdir ~/.ovpn
chmod 700 ~/.ovpn # keep it secret
cd .ovpn
cp ~/Downloads/my.ovpn ./my.inline.ovpn
Then run it like this:
ruby ~/Downloads/ovpnsplit.rb my.inline.ovpn > my.ovpn
Now if you have a look in that folder you should have the following files:
$ ls ~/.ovpn
ca.crt
client.crt
client.key
my.ovpn
my.inline.ovpn
ta.key
And when you look in the my.ovpn
file you will see the inline certs have been replaced with paths:
remote vpn.example.com 1194
proto udp
ns-cert-type server
client
dev tun
resolv-retry infinite
keepalive 10 120
nobind
comp-lzo
verb 3
;user nobody
;group nogroup
key-direction 1
ca ca.crt
key client.key
cert client.crt
tls-auth ta.key 1
Now you can import that file into Network Manager.
- make this a gem for ease of use
- verify the generated file contents against the original file
- handle file without
tls-auth
sections
This worked perfectly! Thank you for saving me a job!