-
cd
to the directory where your 4 files are. (client.ovpn
,client.key
,client.crt
, andca.crt
) -
Call
unify-ovpn.sh
with the filename of your ovpn fileunify-ovpn.sh client.ovpn
-
A new file named
client_unified.ovpn
will be created
Last active
July 19, 2021 09:18
-
-
Save RichardBronosky/331f975bba6697e5a15217233d280c06 to your computer and use it in GitHub Desktop.
Create a single-file "unified format" ovpn file from the legacy client.ovpn client.key client.crt ca.crt four-file format.
This file contains hidden or 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
#!/bin/bash | |
src=$1 | |
dst="$(basename $src .ovpn)_unified.ovpn" | |
gawk -f - $src > $dst << 'AWK' | |
BEGIN { | |
RS="\n|\r\n" | |
} | |
function readcert(file) { | |
while ((getline < file) > 0) { | |
contents = contents RT $0 | |
if ($1 == "-----BEGIN") | |
contents = $0 | |
if ($1 == "-----END") | |
break | |
} | |
close(file) | |
return contents | |
} | |
$1 ~ /^(ca|key|cert)$/ { | |
tag = $1 | |
print "#" $0 | |
print "<" tag ">" | |
print readcert($2) | |
print "</" tag ">" | |
next | |
} | |
{ | |
} | |
AWK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for your script. It would be nice to add support for the authentication key (diff):