diff options
| author | Oleksandr Kuchmystyi <o.kuchmystyi@vyos.io> | 2025-09-17 16:33:39 +0300 |
|---|---|---|
| committer | Oleksandr Kuchmystyi <o.kuchmystyi@vyos.io> | 2025-09-30 17:37:52 +0300 |
| commit | 68f2cec785b6705c71d17b30114355569c489d66 (patch) | |
| tree | d3fae021d1be76a55d6e5c73535b0b4459a07d12 /data | |
| parent | a3b62f290a90a374dca04c6400fd1619f36e808f (diff) | |
| download | vyos-1x-68f2cec785b6705c71d17b30114355569c489d66.tar.gz vyos-1x-68f2cec785b6705c71d17b30114355569c489d66.zip | |
syslog: T4251: Add TLS support to syslog
Add TLS support for remote syslog by extending the CLI and backend to support configuration of CA certificates, client certificates, keys, and authentication modes.
This update integrates with the PKI subsystem for certificate management, ensures proper validation of protocol settings when TLS is enabled, and generates secure rsyslog configuration for forwarding logs over TLS.
Diffstat (limited to 'data')
| -rw-r--r-- | data/templates/rsyslog/rsyslog.conf.j2 | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/data/templates/rsyslog/rsyslog.conf.j2 b/data/templates/rsyslog/rsyslog.conf.j2 index 6ef2afcaf..07dbc603d 100644 --- a/data/templates/rsyslog/rsyslog.conf.j2 +++ b/data/templates/rsyslog/rsyslog.conf.j2 @@ -92,6 +92,7 @@ if prifilt("{{ tmp | join(',') }}") then { {% set _ = tmp.append(facility.replace('all', '*') ~ "." ~ facility_options.level.replace('all', 'debug')) %} {% endfor %} {% set _ = tmp.sort() %} +{% set tls = remote_options.tls %} # Remote syslog to {{ remote_name }} if prifilt("{{ tmp | join(',') }}") then { action( @@ -100,7 +101,7 @@ if prifilt("{{ tmp | join(',') }}") then { target="{{ remote_name }}" # Port on the remote syslog server port="{{ remote_options.port }}" - protocol="{{ remote_options.protocol }}" + protocol="{{ 'tcp' if tls.enable is vyos_defined else remote_options.protocol }}" {% if remote_options.format.include_timezone is vyos_defined %} template="RSYSLOG_SyslogProtocol23Format" {% endif %} @@ -111,6 +112,31 @@ if prifilt("{{ tmp | join(',') }}") then { {% if remote_options.vrf is vyos_defined %} Device="{{ remote_options.vrf }}" {% endif %} +{% if tls.enable is vyos_defined %} +{% set auth_mode = tls.auth_mode %} + # Specify the use of the OpenSSL TLS driver for this action + StreamDriver="ossl" + # Set mode to TLS-only connections (do not accept plain TCP) + StreamDriverMode="1" + # Select the authentication mode + StreamDriverAuthMode="{{ auth_mode if auth_mode == 'anon' else 'x509/' + auth_mode }}" +{% if tls.permitted_peers is vyos_defined and auth_mode in ('fingerprint', 'name') %} + # Only include permitted peers (list of allowed fingerprints or names) + StreamDriverPermittedPeers="{{ tls.permitted_peers }}" +{% endif %} +{% if tls.ca_certificate_path is vyos_defined %} + # Include the path to the CA certificate file + StreamDriver.CAFile="{{ tls.ca_certificate_path }}" +{% endif %} +{% if tls.certificate_path is vyos_defined %} + # Include the path to the client's certificate + StreamDriver.CertFile="{{ tls.certificate_path }}" +{% endif %} +{% if tls.certificate_key_path is vyos_defined %} + # Include the path to the client's private key + StreamDriver.KeyFile="{{ tls.certificate_key_path }}" +{% endif %} +{% endif %} ) } {% endif %} |
