From 720e6c3e77bf552164dcaac914dc821c0dcb8818 Mon Sep 17 00:00:00 2001 From: Christian Zeitnitz Date: Sat, 27 Mar 2021 10:29:09 +0100 Subject: [PATCH 1/2] Add certificate option to openvpn GUI add JS code to display options and selected ovpn file --- app/js/custom.js | 16 +++++++ includes/openvpn.php | 2 +- templates/openvpn/configs.php | 6 +-- templates/openvpn/general.php | 83 ++++++++++++++++++++++++----------- 4 files changed, 77 insertions(+), 30 deletions(-) diff --git a/app/js/custom.js b/app/js/custom.js index d5047558..cd142a89 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -281,6 +281,22 @@ $('#ovpn-confirm-activate').on('shown.bs.modal', function (e) { $('.btn-activate', this).data('recordId', data.recordId); }); +$('#ovpn-userpw,#ovpn-certs').on('click', function (e) { +// e.stopPropagation(); + if (this.id == 'ovpn-userpw') { + $('#PanelCerts').hide(); + $('#PanelUserPW').show(); + } else if (this.id == 'ovpn-certs') { + $('#PanelUserPW').hide(); + $('#PanelCerts').show(); + } +}); + +// Add the following code if you want the name of the file appear on select +$(".custom-file-input").on("change", function() { + var fileName = $(this).val().split("\\").pop(); + $(this).siblings(".custom-file-label").addClass("selected").html(fileName); +}); /* Sets the wirelss channel select options based on hw_mode and country_code. diff --git a/includes/openvpn.php b/includes/openvpn.php index 810746a2..c5b00d1c 100755 --- a/includes/openvpn.php +++ b/includes/openvpn.php @@ -53,7 +53,7 @@ function DisplayOpenVPNConfig() $authUser = current($auth); $authPassword = next($auth); } - $clients = preg_grep('~\login.(conf)$~', scandir(pathinfo(RASPI_OPENVPN_CLIENT_LOGIN, PATHINFO_DIRNAME))); + $clients = preg_grep('/client.(conf)$/', scandir(pathinfo(RASPI_OPENVPN_CLIENT_CONFIG, PATHINFO_DIRNAME))); $logEnable = 0; if (!empty($_POST) && !isset($_POST['log-openvpn'])) { diff --git a/templates/openvpn/configs.php b/templates/openvpn/configs.php index 6f8056fd..dc624c63 100644 --- a/templates/openvpn/configs.php +++ b/templates/openvpn/configs.php @@ -8,11 +8,11 @@

diff --git a/templates/openvpn/general.php b/templates/openvpn/general.php index f8f2052c..9494bf0c 100644 --- a/templates/openvpn/general.php +++ b/templates/openvpn/general.php @@ -1,35 +1,66 @@

-
-
-
-
-
-
+
+
+
+
+
+
-
-
- - -
+
+
+
+ +
-
-
- - -
+
+ +
-
-
-
- - -
-
-
-
-
+
+
+
+
+
Enter username and password
+
+
+
+ + +
+
+ + +
+
+
+
+
+
Certificates in the configuration file
+

RaspAP does not support the import of the required cerficates. Please paste them into the configuration file +

    +
  • Signing certification authority (CA) certificate (e.g. ca.crt): enclosed in <ca> ... </ca> tags
  • +
  • Client certificate (public key) (e.g. client.crt): enclosed in <cert> ... </cert> tags
  • +
  • Private key of the client certificate (e.g. client.key): enclosed in <key> ... </key> tags
  • +
+

+
+
+
+
+
+
+
Configuration File
+
+ + +
+
+
+ +
+
From 72ae09461de61546e2b1d1f8bc3ebdc24b881296 Mon Sep 17 00:00:00 2001 From: Christian Zeitnitz Date: Sat, 27 Mar 2021 11:22:26 +0100 Subject: [PATCH 2/2] Fix form --- templates/openvpn/general.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/openvpn/general.php b/templates/openvpn/general.php index 9494bf0c..7a33163d 100644 --- a/templates/openvpn/general.php +++ b/templates/openvpn/general.php @@ -8,7 +8,6 @@
-
@@ -37,6 +36,9 @@
+
+
Enter username and password
+
Certificates in the configuration file

RaspAP does not support the import of the required cerficates. Please paste them into the configuration file

    @@ -58,7 +60,6 @@
-