Overview
TLS (Transport Layer Security) options enable encrypted connections between NATS clients and servers, ensuring secure communication and optional client authentication through certificates.Command Line Flags
Enable TLS without client certificate verification.
Path to server certificate file (PEM format).
Path to server private key file (PEM format).
Enable TLS and verify client certificates.
Path to certificate authority (CA) file for verifying client certificates.
Configuration File Options
Basic TLS Configuration
Path to server certificate file.
Path to server private key file.
Path to certificate authority file for client verification.
Client Verification
Verify client certificates. Requires
ca_file.Verify client certificates and map certificate fields to user authentication.
Skip certificate verification (for testing only).
Cipher and Protocol Configuration
List of allowed cipher suites. Restricts which encryption algorithms can be used.
Elliptic curves for ECDHE cipher suites.
Minimum TLS protocol version. Options:
1.0, 1.1, 1.2, 1.3Performance and Timeout
TLS handshake timeout in seconds.
TLS handshake rate limit in bytes per second.
Perform TLS handshake before sending INFO protocol.
Fallback timeout when
handshake_first is enabled.Certificate Pinning
SHA256 fingerprints of pinned certificates.
Configuration Examples
Basic TLS Server
TLS with Client Verification
Mutual TLS (mTLS) with Certificate Mapping
High Security Configuration
Cluster with TLS
Multiple Certificates
Generating Test Certificates
For development and testing:Available Cipher Suites
Modern recommended cipher suites:TLS_AES_128_GCM_SHA256(TLS 1.3)TLS_AES_256_GCM_SHA384(TLS 1.3)TLS_CHACHA20_POLY1305_SHA256(TLS 1.3)TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305
Monitoring TLS Connections
Check TLS connection status via monitoring:tls_version and tls_cipher_suite fields in connection details.
Best Practices
- Protocol Version: Use TLS 1.2 or higher (preferably 1.3)
- Strong Ciphers: Configure modern cipher suites, avoid weak algorithms
- Certificate Management: Use proper PKI and rotate certificates regularly
- Client Verification: Enable
verifyorverify_and_mapin production - Certificate Expiry: Monitor certificate expiration dates
- Private Keys: Protect private keys with appropriate file permissions (0600)
- CA Trust: Use properly signed certificates from trusted CAs in production
- Separate Certificates: Use different certificates for client and cluster connections
- Timeout Tuning: Adjust
timeoutbased on network conditions - Testing: Always test TLS configuration before deploying to production
Certificate Mapping
When usingverify_and_map: true, NATS maps certificate fields to users:
CN=alice will be authenticated as user alice.
Troubleshooting
Certificate Errors
Common Issues
- Certificate expired: Check expiration with
openssl x509 -enddate - Hostname mismatch: Ensure certificate CN/SAN matches server hostname
- CA not trusted: Verify
ca_filecontains the correct CA certificate - Permission denied: Check file permissions on certificate and key files
- Handshake timeout: Increase
timeoutvalue
Related Configuration
Server Options
Core server configuration
Cluster Options
Secure cluster with TLS
JetStream Options
Secure JetStream with TLS