-
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
-
-
Save erdoukki/854af97f0a5e3ff2aa7cb28b80e10896 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 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