Split .ovpn file to ca, cert and key with awk

With the following awk commands one can simply extract ca, cert and key files:

awk '/<ca>/{flag=1;next}/<\/ca>/{flag=0}flag' client.ovpn > server-ca.pem
awk '/<cert>/{flag=1;next}/<\/cert>/{flag=0}flag' client.ovpn > server.crt
awk '/<key>/{flag=1;next}/<\/key>/{flag=0}flag' client.ovpn > server.key
Bookmark the permalink.

One Response to Split .ovpn file to ca, cert and key with awk

  1. In a word… Indispensible. I work with OpenVPN a lot and this little ditty is going in a bash script – Many thanks 😀

Leave a Reply

Your email address will not be published. Required fields are marked *