networking:openvpn:openvpn:openvpn-info
Table of Contents
OpenVPN Explanation
How the Keys and Cryptographic Pieces Work Together
OpenVPN splits traffic across a control channel (handshakes, authentication, key negotiation, pushing routes/DNS) and a data channel (encrypted VPN packets using symmetric ciphers such as AES-256-GCM or ChaCha20-Poly1305).
- PKI (Public Key Infrastructure) & Certificate Authority (CA): A trust hierarchy anchored by a CA certificate (
ca.crt) and private key (ca.key). The CA signs server and client certificates so each peer can verify identity without pre-sharing secrets with every single device. Keepca.keyoffline or tightly locked down because anyone with it can forge trusted certificates. - Client (and Server) Certificate & Key Pair: Each endpoint generates its own private key (
client.key/server.key) and a certificate signing request (CSR). The CA signs the CSR to produce a certificate (client.crt/server.crt) containing the public key and identity metadata (such as Common Name and Extended Key Usage). Private keys stay secret on their respective machines. - Diffie-Hellman (DH) Parameters: An asymmetric key-agreement method used during the TLS handshake so the client and server can independently compute the same shared secret over an untrusted network without sending that secret across the wire. Combined with ephemeral keys, this provides forward secrecy (past sessions stay safe even if a long-term key is later exposed). Modern setups often use elliptic-curve key exchange (ECDHE) alongside or instead of classic finite-field DH parameters.
tls-auth(andtls-crypt): A static pre-shared HMAC key (ta.key) that signs TLS control-channel handshake packets. If an incoming handshake packet lacks a valid HMAC signature, OpenVPN drops it immediately — blocking unauthenticated scanners, port probes, and denial-of-service floods before the TLS stack even processes them. Modern OpenVPN deployments generally prefertls-cryptortls-crypt-v2, which both authenticates and encrypts control-channel packets so handshake metadata is hidden.
Step-by-Step Setup Flow
Using Easy-RSA (a script wrapper around OpenSSL) is the standard way to practice building these artifacts cleanly:
- Initialize PKI & Build the CA: Create the PKI directory and generate the CA key and certificate (
ca.keyandca.crt). - Generate Server Key & Certificate: Create the server private key, sign its certificate with the CA (marked for server authentication), and keep
server.keyon the VPN server. - Generate Client Key(s) & Certificate(s): Create a separate key pair and certificate for each user or device (often bundled into a
.p12/ PKCS#12 file or embedded into a.ovpnclient profile). - Generate Control-Channel & Key-Exchange Material: Generate the
tls-auth/tls-cryptstatic key (ta.key) and Diffie-Hellman parameters (dh.pem). - Configure & Connect: Point the server and client
.conf/.ovpnprofiles toca.crt, their respective.crt/.keypair, and theta.key/ DH parameters, then verify logs (Initialization Sequence Completed).
Links
- Official CA & Key Generation Guide: OpenVPN Community Docs — Setting Up Your Own CA and Generating Certificates/Keys
- External PKI Walkthrough (Easy-RSA + OpenSSL): OpenVPN Docs — Tutorial: Configure External PKI with Easy-RSA
networking/openvpn/openvpn/openvpn-info.txt · Last modified: by oscar
