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:
Monviech 2026-02-17 16:15:33 +01:00 committed by GitHub
parent ab102b588b
commit 242fc74ccb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View file

@ -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 [

View file

@ -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);
}
});