From a945e8b64d2a7e164ae19aefc34dc7aaa5ba875a Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 19 Nov 2018 18:24:08 +0100 Subject: [PATCH] Openvpn export, add p12 password input for https://github.com/opnsense/core/issues/2787 --- .../OPNsense/OpenVPN/Api/ExportController.php | 5 ++++ .../OPNsense/OpenVPN/forms/export_options.xml | 7 ++++++ .../app/views/OPNsense/OpenVPN/export.volt | 23 ++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/OpenVPN/Api/ExportController.php b/src/opnsense/mvc/app/controllers/OPNsense/OpenVPN/Api/ExportController.php index 0b2acdaab..153d6967d 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/OpenVPN/Api/ExportController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/OpenVPN/Api/ExportController.php @@ -380,6 +380,11 @@ class ExportController extends ApiControllerBase // overlay (saved) user settings if ($this->request->hasPost('openvpn_export')) { $response = $this->storePresetsAction($vpnid); + // p12 password shouldn't be saved to the config, so we need to copy the content here as + // not defined in either model or configuration data. + if (!empty($this->request->getPost('openvpn_export')['p12_password'])) { + $config['p12_password'] = $this->request->getPost('openvpn_export')['p12_password']; + } } foreach ($this->getModel()->getServer($vpnid)->iterateItems() as $key => $value) { if ($value !== "") { diff --git a/src/opnsense/mvc/app/controllers/OPNsense/OpenVPN/forms/export_options.xml b/src/opnsense/mvc/app/controllers/OPNsense/OpenVPN/forms/export_options.xml index 0e9800c39..2b85cebf0 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/OpenVPN/forms/export_options.xml +++ b/src/opnsense/mvc/app/controllers/OPNsense/OpenVPN/forms/export_options.xml @@ -31,6 +31,13 @@ checkbox Use a random local source port (lport) for traffic from the client. Without this set, two clients may not run concurrently. + + openvpn_export.p12_password + + + password + Use a password to protect the pkcs12 file contents + openvpn_export.validate_server_cn diff --git a/src/opnsense/mvc/app/views/OPNsense/OpenVPN/export.volt b/src/opnsense/mvc/app/views/OPNsense/OpenVPN/export.volt index e78dd6e2f..1759317b7 100644 --- a/src/opnsense/mvc/app/views/OPNsense/OpenVPN/export.volt +++ b/src/opnsense/mvc/app/views/OPNsense/OpenVPN/export.volt @@ -24,6 +24,13 @@ # POSSIBILITY OF SUCH DAMAGE. #} + +