mirror of
https://github.com/opnsense/core.git
synced 2026-02-18 18:18:13 -05:00
vpn/openvpn: Use tls-crypt and tls-auth aliases for generating the static key (#9810)
* vpn/openvpn: Even though openvpn --genkey secret generates the same static key for secret, tls-auth and tls-crypt, it is more explicit to use all modes verbatim. It's simpler to expand it in the future this way.
This commit is contained in:
parent
ab102b588b
commit
242fc74ccb
2 changed files with 9 additions and 4 deletions
|
|
@ -98,7 +98,7 @@ class InstancesController extends ApiMutableModelControllerBase
|
|||
|
||||
public function genKeyAction($type = 'secret')
|
||||
{
|
||||
if (in_array($type, ['secret', 'auth-token'])) {
|
||||
if (in_array($type, ['secret', 'auth-token', 'tls-auth', 'tls-crypt'])) {
|
||||
$key = (new Backend())->configdpRun("openvpn genkey", [$type]);
|
||||
if (strpos($key, '-----BEGIN') !== false) {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -81,9 +81,14 @@
|
|||
$("#row_statickey\\.mode > td:eq(1) > div:last").before($("#keygen_div").detach().show());
|
||||
$("#control_label_instance\\.auth-gen-token-secret").before($("#keygen_auth_token_div").detach().show());
|
||||
|
||||
$("#keygen").click(function(){
|
||||
ajaxGet("/api/openvpn/instances/gen_key/secret", {}, function(data, status){
|
||||
if (data.result && data.result === 'ok') {
|
||||
$("#keygen").click(function() {
|
||||
let statickey_mode = $("#statickey\\.mode").val();
|
||||
const mode_map = {
|
||||
auth: "tls-auth",
|
||||
crypt: "tls-crypt"
|
||||
};
|
||||
ajaxGet("/api/openvpn/instances/gen_key/" + mode_map[statickey_mode], {}, function(data){
|
||||
if (data.result === 'ok') {
|
||||
$("#statickey\\.key").val(data.key);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue