Authentication overview
OpenVPN supports several authentication approaches, which can be combined for defense-in-depth:- Certificate-based
- Static key
- Additional auth
TLS/SSL certificatesThe primary authentication method using PKI:
- X.509 certificates for peer identity
- RSA or ECDSA key pairs
- Certificate Authority (CA) validation
- Optional certificate attributes validation
TLS/SSL certificate authentication
The SSL/TLS security model is OpenVPN’s primary authentication mechanism, providing strong identity verification and key exchange.Certificate-based authentication flow
- Initialization: Each peer loads its certificate, private key, and CA certificate
- TLS handshake: Peers establish a secure control channel
- Certificate validation: Each peer validates the other’s certificate chain
- Key derivation: Session keys are derived from TLS key material
- Data channel setup: Encrypted data channel established with derived keys
OpenVPN is tightly bound to the OpenSSL library and derives much of its crypto capabilities from it. It also supports mbedTLS as an alternative backend.
TLS session structure
Fromsrc/openvpn/ssl.h:147:
- Certificate and key material
- CA and CRL information
- TLS cipher configuration
- Cryptographic parameters
Certificate validation
OpenVPN performs rigorous certificate validation:Standard validation
Standard validation
Automatic certificate checks
- Certificate signature verification against CA
- Certificate expiration date validation
- Certificate revocation list (CRL) checking
- Certificate purpose validation
- Certificate chain validation
Additional validation options
Additional validation options
Extended validation options
--remote-cert-tls- Verify remote certificate type (client/server)--verify-x509-name- Verify certificate subject or SAN--tls-verify- Custom verification script--crl-verify- Check certificate revocation
Certificate attributes
Certificate attributes
X.509 field extractionFrom OpenVPN can extract and validate various certificate fields:
src/openvpn/ssl.h:121:- Common Name (CN)
- Subject Alternative Names (SAN)
- Organization (O)
- Organizational Unit (OU)
- Email address
Key exchange methods
OpenVPN uses key method 2 for TLS-based key exchange:- Uses TLS PRF (Pseudo-Random Function) with label “OpenVPN”
- Derives separate keys for each direction
- Supports perfect forward secrecy
- Allows periodic key renegotiation
Key method 2 has been the standard since OpenVPN 2.0. Earlier key methods are no longer supported.
TLS key export
Modern OpenVPN versions support TLS key material export as defined in RFC 5705: Fromsrc/openvpn/ssl.h:87:
- Standardized key derivation
- Better security properties
- Compatibility with modern TLS libraries
Static key authentication
Static key mode uses a pre-shared secret key for both authentication and encryption.Generating static keys
From the documentation indoc/man-sections/encryption-options.rst:66:
Static key structure
Fromsrc/openvpn/crypto.h:151:
Key direction
Static keys can be used bidirectionally or unidirectionally:Username/password authentication
OpenVPN can layer username/password authentication on top of certificate authentication.Client-side configuration
Fromsrc/openvpn/ssl.h:391:
Server-side validation
The server validates credentials through:- PAM (Pluggable Authentication Modules)
- Authentication scripts via
--auth-user-pass-verify - Management interface
- Authentication plugins
Authentication plugins
Authentication plugins
Plugin-based authenticationFrom Plugins can implement:
src/openvpn/ssl.h:212:- Custom authentication backends
- Integration with existing auth systems
- Two-factor authentication
- LDAP/Active Directory integration
Authentication caching
OpenVPN supports authentication caching to avoid repeated authentication:Auth tokens allow clients to reconnect without re-authenticating for a configured period, improving user experience while maintaining security.
TLS authentication (tls-auth)
TLS-auth adds an HMAC signature to all TLS handshake packets, providing:- Protection against port scanning
- DoS attack mitigation
- Additional authentication layer
- Replay protection for control channel
doc/man-sections/encryption-options.rst:71:
TLS encryption (tls-crypt)
TLS-crypt improves upon tls-auth by encrypting control channel packets:- Encrypts control channel packets
- Hides more information from attackers
- Simpler configuration (no direction parameter)
- Better protection against traffic analysis
TLS-crypt v2
TLS-crypt v2 adds per-client keys and metadata support: Fromdoc/man-sections/encryption-options.rst:87:
- Per-client revocation
- Client metadata embedding
- Server-side key management
- Improved scalability
TLS-crypt v2 client keys are wrapped using the server key, allowing the server to unwrap and validate them while maintaining per-client key isolation.
Authentication password management
OpenVPN provides functions for secure password handling:Purging authentication data
For security, OpenVPN can purge cached authentication:- User logs out
- Connection terminates
- Security policy requires credential clearing
PKCS#11 smart card support
OpenVPN supports hardware security tokens via PKCS#11:- Private keys never leave the hardware device
- PIN-based access control
- Physical token possession required
- Compliance with high-security requirements
Authentication protocol features
OpenVPN implements several protocol features to enhance authentication:IV_PROTO authentication flags
Fromsrc/openvpn/ssl.h:90:
- Deferred authentication (for 2FA prompts)
- Temporary authentication failures
- Enhanced authentication signaling
AUTH_PENDING support
Allows servers to defer authentication while waiting for external validation:- Two-factor authentication
- Out-of-band verification
- Manual approval processes
Security best practices
- Certificate auth
- Static keys
- Defense in depth
Certificate authentication best practices:
- Use certificate expiration (1-2 years recommended)
- Implement CRL or OCSP for revocation
- Verify certificate attributes with
--remote-cert-tls - Use strong key sizes (2048-bit RSA minimum, 256-bit ECDSA)
- Protect private keys with encryption and proper permissions
- Use separate CA for VPN certificates
Related documentation
- Architecture - OpenVPN architecture overview
- Tunneling modes - Point-to-point vs client-server modes
- Encryption - Encryption and cipher information