Overview
OpenVPN uses different ciphers for the control channel (TLS) and data channel (VPN traffic). This guide focuses on data channel cipher configuration and negotiation.Cipher negotiation
OpenVPN 2.4 and later support automatic cipher negotiation between client and server.How negotiation works
When both client and server are OpenVPN 2.5 or later:Client announces supported ciphers
The client sends its list of supported ciphers from
--data-ciphers to the server.Server selects cipher
The server picks the first cipher from its
--data-ciphers list that is also supported by the client.Data cipher configuration
Default ciphers
OpenVPN 2.5:Setting data ciphers
The server’s cipher order takes precedence. The first cipher in the server’s list that is also in the client’s list will be selected.
Viewing available ciphers
Recommended ciphers
Modern secure ciphers (AEAD)
AEAD (Authenticated Encryption with Associated Data) ciphers provide both encryption and authentication:| Cipher | Key Size | Performance | Security | Recommendation |
|---|---|---|---|---|
| AES-256-GCM | 256-bit | Excellent with AES-NI | Excellent | Recommended |
| AES-128-GCM | 128-bit | Excellent with AES-NI | Excellent | Recommended |
| CHACHA20-POLY1305 | 256-bit | Excellent on mobile | Excellent | Recommended |
AEAD ciphers don’t use the
--auth option. Authentication is built into the cipher.Legacy ciphers (CBC mode)
| Cipher | Key Size | Security | Status |
|---|---|---|---|
| AES-256-CBC | 256-bit | Good (with auth) | Legacy |
| AES-128-CBC | 128-bit | Good (with auth) | Legacy |
| BF-CBC (Blowfish) | 128-bit | Weak | Deprecated |
| DES-CBC | 56-bit | Broken | Insecure |
Cipher recommendations by use case
Cipher configuration options
data-ciphers (preferred method)
Specifies the list of allowed data channel ciphers for negotiation:cipher (fallback method)
Specifies a single cipher for non-negotiating clients:In OpenVPN 2.5+ with
--compat-mode 2.4.x or lower, the --cipher value is automatically added to --data-ciphers for backwards compatibility.data-ciphers-fallback
Specifies the cipher to use when negotiation fails:Authentication configuration
For CBC mode ciphers
CBC mode ciphers require a separate HMAC authentication:Viewing available digests
Recommended authentication algorithms
| Algorithm | Output Size | Security | Status |
|---|---|---|---|
| SHA512 | 512-bit | Excellent | Recommended |
| SHA384 | 384-bit | Excellent | Recommended |
| SHA256 | 256-bit | Excellent | Recommended |
| SHA1 | 160-bit | Weak | Deprecated |
| MD5 | 128-bit | Broken | Insecure |
For AEAD ciphers (GCM, CHACHA20-POLY1305), the
--auth option is ignored as authentication is built into the cipher.Backward compatibility
Supporting OpenVPN 2.4 clients
OpenVPN 2.4 clients announce support for AES-256-GCM and AES-128-GCM by default:Supporting OpenVPN 2.3 clients
Older clients without negotiation support:Supporting OpenVPN 3 clients
OpenVPN 3-based clients (mobile apps):OpenVPN 3 clients always announce support for all AEAD ciphers and may disable legacy CBC ciphers.
Cipher negotiation scenarios
Example 1: Modern setup
Example 2: Mixed environment
- Modern client uses AES-256-GCM (negotiated)
- Legacy client uses AES-256-CBC (fallback)
Example 3: No common cipher
AUTH_FAILED,Data channel cipher negotiation failed.
Blowfish deprecation
Blowfish (BF-CBC) was the default cipher in OpenVPN 2.4 and earlier.Migrating from Blowfish
Performance considerations
Hardware acceleration
Check if your CPU supports AES-NI:Cipher performance comparison
| Cipher | With AES-NI | Without AES-NI | Mobile |
|---|---|---|---|
| AES-256-GCM | Excellent | Good | Good |
| AES-128-GCM | Excellent | Good | Good |
| CHACHA20-POLY1305 | Good | Good | Excellent |
| AES-256-CBC | Very Good | Fair | Fair |
On systems with AES-NI hardware acceleration, AES-GCM ciphers typically outperform CHACHA20-POLY1305. On mobile devices without AES-NI, CHACHA20-POLY1305 often performs better.
Benchmarking ciphers
Packet format and overhead
AEAD cipher packet format
CBC cipher packet format
Overhead calculation
For AEAD ciphers:- Opcode: 1 byte
- Packet ID: 4 bytes
- Auth Tag: 16 bytes
- Total overhead: 21 bytes
- HMAC: 20-64 bytes (depends on
--auth) - IV: 16 bytes
- Packet ID: 4 bytes
- Total overhead: 40-84 bytes
Advanced configuration
Disabling cipher negotiation
Compatibility mode
Testing cipher configuration
Security best practices
- Use only AEAD ciphers - AES-GCM and CHACHA20-POLY1305 provide best security
-
Prioritize by security - List strongest ciphers first in
--data-ciphers - Avoid deprecated ciphers - Do not use BF-CBC, DES, or 3DES
- Remove CBC mode - Transition to AEAD-only when possible
- Regular updates - Keep OpenVPN updated to support latest ciphers
- Test thoroughly - Verify cipher negotiation works before deploying
- Monitor logs - Check which ciphers are actually being used
- Document exceptions - If supporting legacy ciphers, document why and when to remove
Troubleshooting
No shared cipher error
Error message:- Add common cipher to both client and server
--data-ciphers - Check cipher availability with
openvpn --show-ciphers - Verify crypto library versions support the same ciphers