User Tools

Site Tools


networking:openvpn:openvpn:openvpn-info

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. Keep ca.key offline 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 (and tls-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 prefer tls-crypt or tls-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:

  1. Initialize PKI & Build the CA: Create the PKI directory and generate the CA key and certificate (ca.key and ca.crt).
  2. Generate Server Key & Certificate: Create the server private key, sign its certificate with the CA (marked for server authentication), and keep server.key on the VPN server.
  3. 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 .ovpn client profile).
  4. Generate Control-Channel & Key-Exchange Material: Generate the tls-auth / tls-crypt static key (ta.key) and Diffie-Hellman parameters (dh.pem).
  5. Configure & Connect: Point the server and client .conf / .ovpn profiles to ca.crt, their respective .crt/.key pair, and the ta.key / DH parameters, then verify logs (Initialization Sequence Completed).

networking/openvpn/openvpn/openvpn-info.txt · Last modified: by oscar