Getting that "TLS handshake failed" error in OpenVPN can be particularly frustrating when you're trying to secure SMB traffic across public networks. Let's break down this specific case where a Arch Linux server (2.3.6-1) fails to establish TLS connection with VirtualBox clients.
The client output shows two critical warnings before the handshake failure:
WARNING: file '/etc/openvpn/client-name.key' is group or others accessible
WARNING: file '/etc/openvpn/ta.key' is group or others accessible
These permission issues often prevent OpenVPN from using the key files properly, even if the configuration appears correct.
Let's examine some critical configuration parameters that often cause handshake failures:
# Server side TLS crucial settings
tls-auth /etc/openvpn/ta.key 0 # Key direction matters!
cipher AES-256-CBC # Missing in original config
auth SHA256 # Stronger than default SHA1
# Client side must mirror these
tls-auth /etc/openvpn/ta.key 1 # Note the different direction
remote-cert-tls server # Critical for certificate verification
The handshake failure suggests either:
- Certificate expiration or mismatch
- Missing intermediate certificates
- Incorrect file permissions (as shown in warnings)
Always verify certificates with:
openssl verify -CAfile ca.crt server.crt
openssl verify -CAfile ca.crt client.crt
Before blaming TLS configuration, confirm basic connectivity:
# Test if UDP port 1194 is reachable
nc -zvuw 3 your.server.ip 1194
# Alternative TCP test when debugging
nc -zvw 3 your.server.ip 1194
Based on the specific error pattern, try these solutions in order:
1. Fix key file permissions:
sudo chmod 600 /etc/openvpn/*.key
sudo chmod 644 /etc/openvpn/*.crt
2. Add explicit cipher specification:
echo "cipher AES-256-CBC" | sudo tee -a /etc/openvpn/server.conf
echo "cipher AES-256-CBC" | sudo tee -a /etc/openvpn/client.conf
3. Update tls-auth to tls-crypt for better security:
mv /etc/openvpn/ta.key /etc/openvpn/tls-crypt.key
Replace tls-auth with tls-crypt in both configs
When standard debugging fails, capture handshake packets:
# On server (run as root):
tcpdump -i eth0 udp port 1194 -w vpn.pcap
# On client:
tcpdump -i eth0 udp port 1194 -w vpn-client.pcap
Analyze with Wireshark, filtering for "tls" to see where the handshake breaks.
The OpenVPN 2.3.6 + OpenSSL 1.0.2d combination can sometimes require:
# Add to both configs if experiencing handshake issues
tls-version-min 1.2
tls-cipher TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384:TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384
Remember that VirtualBox bridged networking can introduce additional NAT complications. Consider testing with NAT network mode temporarily to rule out bridge configuration issues.
When setting up OpenVPN 2.3.6 on Arch Linux to encrypt SMB traffic, you might encounter the frustrating TLS Error: TLS handshake failed
message. This typically occurs during the initial connection phase between client and server, indicating a failure in establishing a secure communication channel.
From the logs, we can see the client fails with:
TLS Error: TLS key negotiation failed to occur within 60 seconds
TLS Error: TLS handshake failed
SIGUSR1[soft,tls-error] received, process restarting
Common troubleshooting steps like switching from UDP to TCP or disabling cipher/TLS authentication often don't resolve the issue, and may lead to other errors like Assertion failed at crypto_openssl.c:523
.
Let's examine the critical parts of both configurations:
Server Configuration (/etc/openvpn/server.conf)
port 1194
proto udp
dev tun
ca /etc/openvpn/ca.crt
cert /etc/openvpn/server-name.crt
key /etc/openvpn/server-name.key
dh /etc/openvpn/dh2048.pem
server 10.8.0.0 255.255.255.0
tls-auth /etc/openvpn/ta.key 0
comp-lzo
Client Configuration (/etc/openvpn/client.conf)
client
dev tun
proto udp
remote [public-ip] 1194
ca /etc/openvpn/ca.crt
cert /etc/openvpn/client-name.crt
key /etc/openvpn/client-name.key
remote-cert-tls server
tls-auth /etc/openvpn/ta.key 1
comp-lzo
1. Certificate Verification Issues
Verify your certificates are properly generated and match:
# On both server and client:
openssl verify -CAfile /etc/openvpn/ca.crt /etc/openvpn/server-name.crt
openssl verify -CAfile /etc/openvpn/ca.crt /etc/openvpn/client-name.crt
2. Time Synchronization
Ensure both machines have synchronized time:
timedatectl status
# If out of sync:
sudo timedatectl set-ntp true
3. TLS Authentication Key Direction
The server uses tls-auth ta.key 0
while client uses 1
. Verify:
# On server:
tls-auth /etc/openvpn/ta.key 0
# On client:
tls-auth /etc/openvpn/ta.key 1
4. Network Connectivity
Test basic connectivity:
nc -vzu [public-ip] 1194
# Or for TCP:
nc -vz [public-ip] 1194
Increase verbosity to 4 or higher in both configurations:
verb 4
Check system logs for additional clues:
journalctl -u openvpn@server -f
# Or for client:
journalctl -u openvpn@client -f
Try this stripped-down configuration to isolate the issue:
Server Minimal Config
port 1194
proto udp
dev tun
server 10.8.0.0 255.255.255.0
ca /etc/openvpn/ca.crt
cert /etc/openvpn/server.crt
key /etc/openvpn/server.key
dh /etc/openvpn/dh.pem
keepalive 10 120
user nobody
group nobody
persist-key
persist-tun
verb 4
Client Minimal Config
client
dev tun
proto udp
remote [public-ip] 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca /etc/openvpn/ca.crt
cert /etc/openvpn/client.crt
key /etc/openvpn/client.key
remote-cert-tls server
verb 4
After making changes:
- Restart OpenVPN services on both ends
- Monitor logs in real-time
- Verify network connectivity
- Check certificate validity periods
Remember that TLS handshake failures can be caused by multiple factors, so methodical elimination of potential issues is key to resolution.