Overview
TLS mode is the most powerful crypto mode of OpenVPN in both security and flexibility. TLS mode works by establishing control and data channels which are multiplexed over a single TCP/UDP port. OpenVPN initiates a TLS session over the control channel and uses it to exchange cipher and HMAC keys to protect the data channel.TLS mode uses a robust reliability layer over the UDP connection for all control channel communication, while the data channel forwards encrypted tunnel data without any mediation.
Certificate requirements
To use TLS mode, each peer that runs OpenVPN should have its own local certificate/key pair (--cert and --key), signed by the root certificate which is specified in --ca.
When two OpenVPN peers connect:
Certificate verification
Each peer checks that its partner peer presented a certificate which was signed by the master root certificate as specified in
--ca.TLS negotiation
If verification succeeds on both peers, the TLS negotiation completes and both OpenVPN peers exchange temporary session keys.
Basic TLS configuration
Server configuration
Client configuration
TLS authentication and encryption
tls-auth: HMAC authentication
The--tls-auth option adds an additional layer of HMAC authentication on top of the TLS control channel to mitigate DoS attacks and attacks on the TLS stack.
The
direction parameter should always be complementary on either side of the connection. One side uses 0 and the other uses 1, or both sides omit it altogether.- Packets without correct HMAC signature are dropped immediately
- Protects against DoS attacks by preventing resource consumption
- Provides replay protection
- Minimal resource usage before authentication
tls-crypt: Encrypted authentication
The--tls-crypt option encrypts and authenticates all control channel packets, providing additional privacy and security.
- Provides more privacy by hiding the certificate used for TLS connection
- Makes it harder to identify OpenVPN traffic
- Provides “poor-man’s” post-quantum security
- No need to set
--key-direction
tls-crypt-v2: Client-specific keys
The--tls-crypt-v2 option uses client-specific tls-crypt keys, which is ideal for large deployments and VPN providers.
Benefits:
- Client-specific keys reduce impact of key compromise
- Improved DoS resilience
- Metadata can be used to identify/reject clients before TLS handshake
- Compatible with servers also supporting
--tls-author--tls-crypt
Metadata verification
Servers can verify client metadata before exposing the TLS stack:TLS version and cipher selection
TLS version constraints
TLS cipher configuration
Elliptic curve configuration
Certificate validation
Remote certificate type verification
Certificate name verification
Fingerprint verification
When using
--peer-fingerprint, specifying a CA with --ca or --capath is optional. This allows peer-fingerprint to be used as an alternative to a full PKI with self-signed certificates.Certificate revocation
If the CRL is missing, OpenVPN will log a warning but still allow the connection. Ensure the user running OpenVPN has read permissions to the CRL file.
Advanced TLS options
Certificate profile restrictions
Handshake timeout
Private key password protection
Best practices
-
Always verify peer certificates using
--remote-cert-tls,--verify-x509-name, or--peer-fingerprint - Use tls-crypt or tls-crypt-v2 for additional security and DoS protection
- Set minimum TLS version to 1.2 or higher
-
Use modern key exchange with
dh noneto rely on ECDH/X25519 - Rotate tls-crypt keys periodically in large deployments
- Implement CRL checking to handle compromised certificates
- Use certificate profiles to enforce minimum cryptographic standards
Troubleshooting
View supported algorithms
Common issues
TLS handshake timeout:- Increase
--hand-windowvalue - Check firewall rules
- Verify time synchronization between peers
- Verify CA certificate matches on both peers
- Check certificate expiration dates
- Ensure certificate chain is complete
- Check
--tls-cipherand--tls-ciphersuitescompatibility - Verify crypto library versions support the same algorithms
- Review
--tls-groupsconfiguration