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
boolean
default:"false"
Enable TLS without client certificate verification.
string
Path to server certificate file (PEM format).
string
Path to server private key file (PEM format).
boolean
default:"false"
Enable TLS and verify client certificates.
string
Path to certificate authority (CA) file for verifying client certificates.
Configuration File Options
Basic TLS Configuration
string
required
Path to server certificate file.
string
required
Path to server private key file.
string
Path to certificate authority file for client verification.
Client Verification
boolean
default:"false"
Verify client certificates. Requires
ca_file.boolean
default:"false"
Verify client certificates and map certificate fields to user authentication.
boolean
default:"false"
Skip certificate verification (for testing only).
Cipher and Protocol Configuration
array
List of allowed cipher suites. Restricts which encryption algorithms can be used.
array
Elliptic curves for ECDHE cipher suites.
string
default:"1.2"
Minimum TLS protocol version. Options:
1.0, 1.1, 1.2, 1.3Performance and Timeout
float
default:"2.0"
TLS handshake timeout in seconds.
integer
TLS handshake rate limit in bytes per second.
boolean
default:"false"
Perform TLS handshake before sending INFO protocol.
duration
Fallback timeout when
handshake_first is enabled.Certificate Pinning
array
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