aboutsummaryrefslogtreecommitdiffstats
path: root/config/openvpn-client-export/openvpn-client-export.inc
diff options
context:
space:
mode:
Diffstat (limited to 'config/openvpn-client-export/openvpn-client-export.inc')
-rwxr-xr-xconfig/openvpn-client-export/openvpn-client-export.inc15
1 files changed, 13 insertions, 2 deletions
diff --git a/config/openvpn-client-export/openvpn-client-export.inc b/config/openvpn-client-export/openvpn-client-export.inc
index 234d7326..b9ac8866 100755
--- a/config/openvpn-client-export/openvpn-client-export.inc
+++ b/config/openvpn-client-export/openvpn-client-export.inc
@@ -541,8 +541,19 @@ EOF;
file_put_contents($crtfile, base64_decode($cert['crt']));
// write user .key
- $keyfile = "{$tempdir}/key.key";
- file_put_contents($keyfile, base64_decode($cert['prv']));
+ if (!empty($outpass)) {
+ $keyfile = "{$tempdir}/key.key";
+ $clearkeyfile = "{$tempdir}/key-clear.key";
+ file_put_contents($clearkeyfile, base64_decode($cert['prv']));
+ $eoutpass = escapeshellarg($outpass);
+ $ekeyfile = escapeshellarg($keyfile);
+ $eclearkeyfile = escapeshellarg($clearkeyfile);
+ exec("/usr/bin/openssl rsa -in ${eclearkeyfile} -out ${ekeyfile} -des3 -passout pass:${eoutpass}");
+ unlink($clearkeyfile);
+ } else {
+ $keyfile = "{$tempdir}/key.key";
+ file_put_contents($keyfile, base64_decode($cert['prv']));
+ }
}
// TLS support?