From 88b1deff55bc9bc6daeeb89478eb564c18446b1c Mon Sep 17 00:00:00 2001 From: jim-p Date: Tue, 27 Apr 2010 10:04:31 -0400 Subject: Define $cafile before use. Ticket #529 --- config/openvpn-client-export/openvpn-client-export.inc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'config/openvpn-client-export') diff --git a/config/openvpn-client-export/openvpn-client-export.inc b/config/openvpn-client-export/openvpn-client-export.inc index 6db3651f..62a1989c 100755 --- a/config/openvpn-client-export/openvpn-client-export.inc +++ b/config/openvpn-client-export/openvpn-client-export.inc @@ -145,7 +145,7 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoke $server_host = $useaddr; $server_port = $settings['local_port']; - $proto = ($settings['protocol'] == 'UDP' ? 'udp' : "tcp-client"); + $proto = (strtoupper($settings['protocol']) == 'UDP' ? 'udp' : "tcp-client"); $cipher = $settings['crypto']; @@ -184,15 +184,16 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoke // add key settings $prefix = openvpn_client_export_prefix($srvid); + $cafile = "{$prefix}-ca.crt"; if($nokeys == false) { if ($usetoken) { - $conf .= "ca {$prefix}-ca.crt\n"; + $conf .= "ca {$cafile}\n"; $conf .= "cryptoapicert \"SUBJ:{$user['name']}\"\n"; } else { $conf .= "pkcs12 {$prefix}.p12\n"; } } else if ($settings['mode'] == "server_user") - $conf .= "ca {$prefix}-ca.crt\n"; + $conf .= "ca {$cafile}\n"; if ($settings['tls']) $conf .= "tls-auth {$prefix}-tls.key 1\n"; @@ -210,7 +211,8 @@ function openvpn_client_export_config($srvid, $usrid, $crtid, $useaddr, $usetoke file_put_contents("{$tempdir}/{$prefix}.ovpn", $conf); - file_put_contents("{$tempdir}/{$prefix}-ca.crt", base64_decode($server_ca['crt'])); + $cafile = "{$tempdir}/{$cafile}"; + file_put_contents("{$cafile}", base64_decode($server_ca['crt'])); if ($settings['tls']) { $tlsfile = "{$tempdir}/{$prefix}-tls.key"; file_put_contents($tlsfile, base64_decode($settings['tls'])); -- cgit v1.2.3