DEV Community

johnettagaweraks
johnettagaweraks

Posted on

OpenVPN needs a peer identity check beyond a valid certificate

OpenVPN needs a peer identity check beyond a valid certificate

A VPN client certificate proves that a peer possesses a matching private key. It does not prove that the peer reached the correct endpoint, that the configured certificate belongs to the intended service, or that a client is authorized for the tunnel profile it requests. OpenVPN deployments should make those identity checks explicit.

OpenVPN 2.6 provides --verify-x509-name for checking the remote certificate name. The manual describes it as a useful replacement for an external --tls-verify command because it can work inside a chroot without command dependencies. The option has a name and a matching mode. The documented modes compare the certificate subject, the common name, or a name prefix. A client that accepts any certificate signed by the configured CA has not verified the server identity in the way an operator usually expects.

The server side has a related question. A client certificate may be valid while its subject, purpose, or issued profile is wrong for the account it is mapped to. Review the CA, certificate extensions, and the authorization path that turns a certificate into an address, route, or group. Revocation is important, but a current certificate can still carry an inappropriate role.

Match the endpoint to a configuration value

For client profiles, set an expected remote name that matches the certificate the server actually presents. Keep it in the reviewed profile rather than relying on the user to notice a warning. Verify that the certificate subject name and the selected match mode agree. A subject check can be too broad if it only looks for a location while the hostname is the real service identity.

For servers, require client certificates and validate them against the intended CA. Separate profiles for administrators, ordinary users, and automation if those populations need different routes or access. Do not let the certificate alone decide authorization. Use the server-side configuration, client-config directory, or an authentication hook to bind a validated identity to a named profile. Record what happens when the user entry is missing.

Certificate lifecycle needs an owner. Inventory issued certificates, expiration dates, serial numbers, and revocation status. Test renewal with the same subject expectations that production uses. A renewal that changes the common name can break --verify-x509-name even when the TLS chain remains valid. A renewal that keeps the name but changes key usage can produce a different failure. Both should be caught before a fleet-wide rollout.

Use tls-crypt as a second boundary

--tls-crypt protects and authenticates the OpenVPN control channel with a pre-shared key. It reduces the amount of protocol metadata visible to an observer and can filter peers that do not hold the key. The OpenVPN manual also documents --tls-crypt-v2 and per-client key metadata verification. Those controls are useful because they can reject a connection before a client-specific credential is processed.

The pre-shared key does not replace certificate identity. A key shared by every client becomes a fleet-wide secret, and a user who obtains it still needs a valid client certificate for a certificate-authenticated tunnel. Treat the key as one layer in a chain. Restrict its distribution, rotate it when membership changes materially, and test whether revoked clients can still reach the TLS stack.

Metadata verification for tls-crypt-v2 should have the same validation character as any other identity check. The command or helper must process bounded input, use a fixed policy source, and fail closed when the metadata source is unavailable. Avoid a verification command that silently accepts an empty result.

Inspect the deployed profile

A configuration review should answer these questions with evidence. Which CA signs the server and clients? Which certificate field does each side compare? What match mode is used? Does the server map a certificate to a specific client profile? What revokes access? What happens when a certificate is renewed?

Run a test with a valid certificate and an intentionally wrong name. The connection should fail with a clear identity error. Run a test with the correct name and a certificate that lacks the intended key usage or has been revoked. Record the failure. Then test the client-config assignment for a new account and for a removed account. A connection that succeeds without the expected authorization is a deployment defect even if the TLS handshake is sound.

OpenVPN remains a transport and access layer, not an application authorization system. Pair certificate checks with network policy, route review, and account revocation. The objective is a peer that is both cryptographically valid and specifically the peer the profile intended to admit.

References

Top comments (0)