From 3c11bd3c5b42e54f341b05f07bf27bc8131d80d3 Mon Sep 17 00:00:00 2001 From: Matthew Grooms Date: Sat, 6 Sep 2008 21:10:43 +0000 Subject: Minor re-work of OpenVPN configuration. Use operational modes to determine what configuration options are appropriate. The operational mode dictates the authentication method. They are defines as follows ... Peer to Peer ( SSL/TLS ) Peer to Peer ( Shared Key ) Remote Access ( SSL/TLS ) Remote Access ( User Auth ) Remote Access ( SSL/TLS + User Auth ) Some of these modes allow for user authentication using passwords. We now use the etc/inc/openvpn.auth-user.php file to facilitate this by checking the username and password supplied by OpenVPN against our centralized user database. The Server and Client user interfaces have also been updated to support TLS packet authentication. This is an additional security option that is optional. --- etc/inc/config.inc | 17 ++++ etc/inc/openvpn.auth-user.php | 79 +++++++++++++++ etc/inc/openvpn.inc | 219 ++++++++++++++++++++++++++---------------- 3 files changed, 231 insertions(+), 84 deletions(-) create mode 100755 etc/inc/openvpn.auth-user.php (limited to 'etc') diff --git a/etc/inc/config.inc b/etc/inc/config.inc index 5a52611..0cd4476 100644 --- a/etc/inc/config.inc +++ b/etc/inc/config.inc @@ -1747,6 +1747,16 @@ endif; $index++; } + /* determine operational mode */ + if ($server['auth_method'] == 'pki') { + if($server['nopool']) + $server['mode'] = "p2p_tls"; + else + $server['mode'] = "server_tls"; + } else + $server['mode'] = "p2p_shared_key"; + unset($server['auth_method']); + /* modify configuration values */ unset($server['dh_params']); if (!$server['interface']) @@ -1829,6 +1839,13 @@ endif; $index++; } + /* determine operational mode */ + if ($client['auth_method'] == 'pki') + $client['mode'] = "p2p_tls"; + else + $client['mode'] = "p2p_shared_key"; + unset($client['auth_method']); + /* modify configuration values */ if (!$client['interface']) $client['interface'] = 'wan'; diff --git a/etc/inc/openvpn.auth-user.php b/etc/inc/openvpn.auth-user.php new file mode 100755 index 0000000..275f54d --- /dev/null +++ b/etc/inc/openvpn.auth-user.php @@ -0,0 +1,79 @@ +#!/usr/local/bin/php -f + diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc index 8dda12e..abc2337 100644 --- a/etc/inc/openvpn.inc +++ b/etc/inc/openvpn.inc @@ -49,13 +49,45 @@ require_once('util.inc'); $openvpn_prots = array("UDP", "TCP"); -$openvpn_auth_methods = array( - 'pki' => "Public Key Infrastructure", - 'shared_key' => "Pre Shared Key"); +/* + * The User Auth mode below is disabled because + * OpenVPN erroneously requires that we provide + * a CA configuration parameter. In this mode, + * clients don't send a certificate so there is + * no need for a CA. If we require that admins + * provide one in the pfSense UI due to a bogus + * requirement imposed by OpenVPN, it could be + * considered very confusing ( I know I was ). + * + * -mgrooms + */ + +$openvpn_server_modes = array( + 'p2p_tls' => "Peer to Peer ( SSL/TLS )", + 'p2p_shared_key' => "Peer to Peer ( Shared Key )", + 'server_tls' => "Remote Access ( SSL/TLS )", +// 'server_user' => "Remote Access ( User Auth )", + 'server_tls_user' => "Remote Access ( SSL/TLS + User Auth )"); + +$openvpn_client_modes = array( + 'p2p_tls' => "Peer to Peer ( SSL/TLS )", + 'p2p_shared_key' => "Peer to Peer ( Shared Key )" ); + +function openvpn_create_key() { + + $fp = popen("/usr/local/sbin/openvpn --genkey --secret /dev/stdout 2>/dev/null", "r"); + if (!$fp) + return false; + + $rslt = stream_get_contents($fp); + pclose($fp); + + return $rslt; +} function openvpn_create_dhparams($bits) { - $fp = popen("/usr/bin/openssl dhparam {$bits}", "r"); + $fp = popen("/usr/bin/openssl dhparam {$bits} 2>/dev/null", "r"); if (!$fp) return false; @@ -268,61 +300,64 @@ function openvpn_reconfigure($mode,& $settings) { $lines = explode(' ', trim(shell_exec("ifconfig {$iface} | grep inet | grep -v inet6"))); $iface_ip = $lines[1]; -$conf .= <<