OpenVPN Inline Certs: Difference between revisions
From Lolly's Wiki
Jump to navigationJump to search
(Die Seite wurde neu angelegt: „Kategorie:OpenVPN To get an OpenVPN-Configuration in one file you can inline all referred files like this: <pre> # nawk ' /^(tls-auth|ca|cert|key)/ { type=$…“) |
m (Text replacement - "</source" to "</syntaxhighlight") |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[ | [[Category:OpenVPN]] | ||
To get an OpenVPN-Configuration in one file you can inline all referred files like this: | To get an OpenVPN-Configuration in one file you can inline all referred files like this: | ||
< | <syntaxhighlight lang=bash> | ||
$ nawk ' | |||
/^(tls-auth|ca|cert|key)/ { | /^(tls-auth|ca|cert|key)/ { | ||
type=$1; | type=$1; | ||
Line 19: | Line 19: | ||
print; | print; | ||
}' connection.ovpn | }' connection.ovpn | ||
</ | </syntaxhighlight> | ||
And inline to files: | |||
<syntaxhighlight lang=bash> | |||
$ nawk ' | |||
/^<(tls-auth|ca|dh|cert|key)>/ { | |||
type=$1; | |||
gsub(/[<>]/,"",type); | |||
file=type".pem"; | |||
print type,file; | |||
print ""> file; | |||
while(getline) { | |||
if($0 == "</"type">"){ | |||
fflush(file); | |||
close(file); | |||
break; | |||
} | |||
print $0>>file;} | |||
next; | |||
} | |||
{ | |||
# All other lines are printed as they are | |||
print $0; | |||
}' connection.ovpn > connection_.ovpn | |||
</syntaxhighlight> |
Latest revision as of 03:37, 26 November 2021
To get an OpenVPN-Configuration in one file you can inline all referred files like this:
$ nawk '
/^(tls-auth|ca|cert|key)/ {
type=$1;
file=$2;
# for tls-auth we need the key-direction
if(type=="tls-auth")print "key-direction",$3;
print "<"type">";
while(getline tlsauth<file)
print tlsauth;
close(file);
print "</"type">";
next;
}
{
# All other lines are printed as they are
print;
}' connection.ovpn
And inline to files:
$ nawk '
/^<(tls-auth|ca|dh|cert|key)>/ {
type=$1;
gsub(/[<>]/,"",type);
file=type".pem";
print type,file;
print ""> file;
while(getline) {
if($0 == "</"type">"){
fflush(file);
close(file);
break;
}
print $0>>file;}
next;
}
{
# All other lines are printed as they are
print $0;
}' connection.ovpn > connection_.ovpn