diff options
author | Jim P <jim@pingle.org> | 2012-11-24 11:18:37 -0800 |
---|---|---|
committer | Jim P <jim@pingle.org> | 2012-11-24 11:18:37 -0800 |
commit | c554c87ba2260e10dd474d6ea56b204fc12234d0 (patch) | |
tree | 79211efbf7b928390de74ac94113e9e8a3759daf /config/openvpn-client-export/openvpn-client-export.inc | |
parent | f034443b1c7271197dcd00b18a62e4b30c408541 (diff) | |
parent | 5ca2674428e6e801ae829e0057b0aca0914d909b (diff) | |
download | pfsense-packages-c554c87ba2260e10dd474d6ea56b204fc12234d0.tar.gz pfsense-packages-c554c87ba2260e10dd474d6ea56b204fc12234d0.tar.bz2 pfsense-packages-c554c87ba2260e10dd474d6ea56b204fc12234d0.zip |
Merge pull request #338 from PiBa-NL/openvpn-client-export-filenames
openvpn-client-export, use certificate common-name in the exported files filenames.
Diffstat (limited to 'config/openvpn-client-export/openvpn-client-export.inc')
-rwxr-xr-x | config/openvpn-client-export/openvpn-client-export.inc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/config/openvpn-client-export/openvpn-client-export.inc b/config/openvpn-client-export/openvpn-client-export.inc index 1ab962da..2fc1147d 100755 --- a/config/openvpn-client-export/openvpn-client-export.inc +++ b/config/openvpn-client-export/openvpn-client-export.inc @@ -61,7 +61,7 @@ function openvpn_client_export_deinstall() { conf_mount_ro(); } -function openvpn_client_export_prefix($srvid, $usrid = null) { +function openvpn_client_export_prefix($srvid, $usrid = null, $crtid = null) { global $config; // lookup server settings @@ -75,12 +75,13 @@ function openvpn_client_export_prefix($srvid, $usrid = null) { $prot = ($settings['protocol'] == 'UDP' ? 'udp' : $settings['protocol']); $port = $settings['local_port']; - $username = ""; - //$config['openvpn']['openvpn-server']; + $filename_addition = ""; if ($usrid && is_numeric($usrid)) - $username = "-".$config['system']['user'][$usrid]['name']; + $filename_addition = "-".$config['system']['user'][$usrid]['name']; + if ($crtid && is_numeric($crtid) && function_exists("cert_get_cn")) + $filename_addition = "-".cert_get_cn($config['cert'][$crtid]['crt']); - return "{$host}-{$prot}-{$port}{$username}"; + return "{$host}-{$prot}-{$port}{$filename_addition}"; } function openvpn_client_pem_to_pk12($outpath, $outpass, $crtpath, $keypath, $capath = false) { @@ -216,7 +217,7 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $quotese $conf .= "http-proxy {$proxy['ip']} {$proxy['port']} "; if ($proxy['proxy_authtype'] != "none") { if (!isset($proxy['passwdfile'])) - $proxy['passwdfile'] = openvpn_client_export_prefix($srvid, $usrid) . "-proxy"; + $proxy['passwdfile'] = openvpn_client_export_prefix($srvid, $usrid, $crtid) . "-proxy"; $conf .= " {$proxy['passwdfile']} {$proxy['proxy_authtype']}"; } $conf .= "{$nl}"; @@ -231,7 +232,7 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $quotese } // add key settings - $prefix = openvpn_client_export_prefix($srvid, $usrid); + $prefix = openvpn_client_export_prefix($srvid, $usrid, $crtid); $cafile = "{$prefix}-ca.crt"; if($nokeys == false) { if ($expformat == "inline") { @@ -478,7 +479,7 @@ function openvpn_client_export_installer($srvid, $usrid, $crtid, $useaddr, $quot exec("/bin/cp {$tempdir}/{$client_install_exe} {$tempdir}/openvpn-install.exe"); // write configuration file - $prefix = openvpn_client_export_prefix($srvid, $usrid); + $prefix = openvpn_client_export_prefix($srvid, $usrid, $crtid); $cfgfile = "{$confdir}/{$prefix}-config.ovpn"; if (!empty($proxy) && $proxy['proxy_authtype'] != "none") { $proxy['passwdfile'] = "{$prefix}-password"; @@ -580,7 +581,7 @@ function viscosity_openvpn_client_config_exporter($srvid, $usrid, $crtid, $usead $tempdir = $tempdir . "/Viscosity.visc/"; // write cofiguration file - $prefix = openvpn_client_export_prefix($srvid, $usrid); + $prefix = openvpn_client_export_prefix($srvid, $usrid, $crtid); if (!empty($proxy) && $proxy['proxy_authtype'] != "none") { $proxy['passwdfile'] = "config-password"; $pwdfle = "{$proxy['user']}\n"; |