Sub topic 14
Encrypting Log Traffic with TLS
Assume you can edit rsyslog configuration with sudo, understand TCP ports and firewalls, and already have a working rsyslog client and central receiver. This chapter adds transport encryption and client authentication to that pipeline.
Why use TLS for logs?
Syslog messages sent over plain TCP are readable by anyone who can observe the network. TLS (Transport Layer Security) encrypts the connection and lets the endpoints authenticate each other with certificates.
TLS does not replace access control. The receiver still needs a firewall rule, and rsyslog still needs permissions to write log files. TLS protects the connection between those endpoints.
| Transport | Encryption | Delivery behavior | Typical use |
|---|---|---|---|
| UDP | No | May lose messages | Low-value local network logs |
| TCP | No | Reliable byte stream | Trusted private networks |
| TCP with TLS | Yes | Reliable byte stream | Sensitive or cross-network logs |
TLS adds certificate management and configuration complexity. Use it when logs contain credentials, personal data, security events, or other information that must not be exposed in transit.
Certificate requirements
Use a certificate authority (CA), which is the trusted issuer of certificates. The receiver and each client should have certificates signed by that CA.
The receiver certificate must contain loghost.example.com in its Subject Alternative Name (SAN). The client checks this name when StreamDriverAuthMode is x509/name.
Each private key must be readable only by the rsyslog process. Store the CA certificate, endpoint certificate, and private key in a protected directory such as /etc/pki/rsyslog/.
Configure the receiver and client
On the receiver, configure the CA and the receiver's own certificate. imtcp is rsyslog's TCP input module. The gtls driver enables TLS, and authentication mode x509/name validates certificate names.
# /etc/rsyslog.d/05-tls.conf on the receiver
global(
DefaultNetstreamDriver="gtls"
DefaultNetstreamDriverCAFile="/etc/pki/rsyslog/ca.pem"
DefaultNetstreamDriverCertFile="/etc/pki/rsyslog/loghost.pem"
DefaultNetstreamDriverKeyFile="/etc/pki/rsyslog/loghost-key.pem"
)
module(load="imtcp"
StreamDriver.Name="gtls"
StreamDriver.Mode="1"
StreamDriver.AuthMode="x509/name")
input(type="imtcp" port="514")On each client, use its own certificate and private key in the global() block. The permitted peer value must match the receiver certificate name.
# /etc/rsyslog.d/50-tls-forward.conf on a client
global(
DefaultNetstreamDriver="gtls"
DefaultNetstreamDriverCAFile="/etc/pki/rsyslog/ca.pem"
DefaultNetstreamDriverCertFile="/etc/pki/rsyslog/client01.pem"
DefaultNetstreamDriverKeyFile="/etc/pki/rsyslog/client01-key.pem"
)
action(type="omfwd"
target="loghost.example.com"
port="514"
protocol="tcp"
StreamDriver="gtls"
StreamDriverMode="1"
StreamDriverAuthMode="x509/name"
StreamDriverPermittedPeers="loghost.example.com")StreamDriverMode="1" selects TLS for the TCP stream. Mutual certificate authentication means the receiver can also require and validate client certificates. Confirm the exact rsyslog and rsyslog-gnutls package support on your distribution before deploying.
Failure modes and verification
A missing CA file, unreadable private key, incorrect SAN, blocked TCP port, or mismatched hostname can prevent forwarding. TLS errors often appear in the journal, so inspect the service logs on both hosts.
Validate syntax before restarting services:
sudo rsyslogd -N1
sudo systemctl restart rsyslog
logger -t tls-demo "encrypted test from $(hostname)"
sudo journalctl -u rsyslog --since "5 minutes ago"Use packet inspection only to confirm that payloads are unreadable. Do not treat a successful TCP connection as proof that certificate validation succeeded.
Exercise
A client connects to port 514, but rsyslog reports a certificate name mismatch. What should you check first?
Show answer
Check that the receiver certificate SAN contains loghost.example.com, that DNS resolves that name to the receiver, and that StreamDriverPermittedPeers uses the same name.