summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authoromnom62 <omnom62@outlook.com>2026-08-11 16:45:15 +1000
committerJohn Estabrook <jestabro@vyos.io>2026-08-26 13:33:34 -0500
commit0cdf7e696b4deb3c3103a596bfe4d4f167dcf4b7 (patch)
tree0d66820d71d2c193e1e7f44f73e7abfca2fa87cb /data
parentf3012e652edef614d4f0ed169b320106a85d83b3 (diff)
downloadvyos-1x-0cdf7e696b4deb3c3103a596bfe4d4f167dcf4b7.tar.gz
vyos-1x-0cdf7e696b4deb3c3103a596bfe4d4f167dcf4b7.zip
http-api: T8989: add mTLS client certificate authentication
Add support for mutual TLS (mTLS) authentication to the VyOS REST API. When configured, nginx requests a client certificate and verifies it against the configured CA chain. FastAPI reads the X-Client-Verify header set by nginx and bypasses API key/token authentication when the client certificate is valid. Configuration: set service https certificates ca-certificate <name> set service https certificates verify-client <optional|required> Note: requires TLSv1.2 due to nginx 1.22 TLSv1.3 post-handshake authentication limitations. TLSv1.3 support pending nginx upgrade.
Diffstat (limited to 'data')
-rw-r--r--data/templates/https/nginx.default.j210
1 files changed, 10 insertions, 0 deletions
diff --git a/data/templates/https/nginx.default.j2 b/data/templates/https/nginx.default.j2
index 1074a997a..1022079b3 100644
--- a/data/templates/https/nginx.default.j2
+++ b/data/templates/https/nginx.default.j2
@@ -48,6 +48,12 @@ server {
ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK';
+{% if certificates.mtls_ca_path is vyos_defined %}
+ # mTLS - client certificate verification (TLSv1.2 required)
+ ssl_client_certificate {{ certificates.mtls_ca_path }};
+ ssl_verify_client optional;
+ ssl_verify_depth 2;
+{% endif %}
# proxy settings for HTTP API, if enabled; 503, if not
location ~ ^/(retrieve|configure|config-file|image|import-pki|container-image|generate|show|reboot|reset|poweroff|ping|traceroute|info|docs|openapi.json|redoc|graphql|renew|token) {
{% if api is vyos_defined %}
@@ -56,6 +62,10 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 600;
proxy_buffering off;
+{% if certificates.mtls_ca_path is vyos_defined %}
+ proxy_set_header X-Client-Verify $ssl_client_verify;
+ proxy_set_header X-Client-DN $ssl_client_s_dn;
+{% endif %}
{% else %}
return 503;
{% endif %}