Openvpn export, add p12 password input for https://github.com/opnsense/core/issues/2787

This commit is contained in:
Ad Schellevis 2018-11-19 18:24:08 +01:00
parent 6bf0dbd70b
commit a945e8b64d
3 changed files with 34 additions and 1 deletions

View File

@ -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 !== "") {

View File

@ -31,6 +31,13 @@
<type>checkbox</type>
<help>Use a random local source port (lport) for traffic from the client. Without this set, two clients may not run concurrently.</help>
</field>
<field>
<id>openvpn_export.p12_password</id>
<label>P12 Password/confirm</label>
<style>password_field</style>
<type>password</type>
<help>Use a password to protect the pkcs12 file contents</help>
</field>
<field>
<id>openvpn_export.validate_server_cn</id>
<label>Validate server CN</label>

View File

@ -24,6 +24,13 @@
# POSSIBILITY OF SUCH DAMAGE.
#}
<style>
.input-spacing {
margin-top: 5px;
margin-bottom: 5px;
}
</style>
<script>
$( document ).ready(function() {
@ -132,9 +139,23 @@
});
}
});
//
});
$("#row_openvpn_export\\.p12_password > td:eq(1)").append($("<hr class='input-spacing'/>"));
$("#row_openvpn_export\\.p12_password > td:eq(1)").append(
$("<input type='password' class='form-control password_field' size='50' id='openvpn_export.p12_password_confirm'/>")
);
$(".password_field").on("keyup", function(){
if ($("#openvpn_export\\.p12_password").val() != $("#openvpn_export\\.p12_password_confirm").val()) {
$(".password_field").addClass("has-warning");
$(".password_field").closest('tr').addClass('has-warning');
} else {
$(".password_field").removeClass("has-warning");
$(".password_field").closest('tr').removeClass('has-warning');
}
});
});