From Root CA to User Authorization in nginx and Apache: Client Certificate Login Explained

This is the third installment in a detailed tutorial series covering the deployment of a two-tier PKI infrastructure with Root CA and intermediate CAs for Person, Server, and Code. The article provides comprehensive configuration guidance for enabling mTLS in nginx and Apache, including full references for all ssl_client_* variables and SSL directives. It explains the differences between password-based and certificate-based authentication, the TLS handshake steps involving CertificateRequest and CertificateVerify, and the importance of proper extendedKeyUsage settings such as clientAuth. Readers learn how to issue client certificates, package them in PKCS#12 format, enforce revocation checks via CRL and OCSP, and safely pass certificate fields to backend applications while mitigating risks from header spoofing. The guide also covers scenarios where the application itself terminates TLS without a reverse proxy and demonstrates login flows protected against CSRF using one-time tokens.

HabrTranslated from Russian

Read at source

This is part three of a practical series on building a complete Root CA to user authorization system using nginx and Apache. The first two parts covered deployment of a two-level PKI with a Root CA and three intermediate CAs (Person, Server, Code), certificate revocation via CRL, and an OCSP responder.

The current part focuses on server-side configuration for client certificate authentication. It explains how to force nginx and Apache to request, validate, and forward X.509 client certificates to applications, and what changes when the application terminates TLS directly without a proxy.

Key differences between password and certificate login are highlighted: with certificates the private key never leaves the client, while the server verifies the signature and builds the chain to a trusted root. The tutorial stresses that the list of accepted CAs must contain only the Person intermediate CA to avoid offering unrelated certificates to users.

Practical steps include issuing a client certificate with extendedKeyUsage = clientAuth and keyUsage containing digitalSignature, packaging it as PKCS#12 for browser import, and enabling mTLS with full directive references. All nine reference tables covering 331 parameters from nginx ngx_http_ssl_module, Apache mod_ssl, and OpenSSL are included.

Special attention is given to secure header passing, login CSRF protection using separate hosts and one-time tokens, and revocation checking on the server side using both CRL and OCSP. The material was verified on nginx 1.29.8, Apache httpd 2.4, OpenSSL 3.3.7, and Go 1.24.

Meridian digestThe week's most consequential security stories, distilled into one briefing.See the digest

More in Other

Mail.ru Reduces Lifetime 1TB Cloud Storage Promo to Standard 8GB Quota for Select Users
Kimi K3 Open Model Surpasses Closed AI Leaders with Million-Token Context and 896 Experts
Innostage Completes Functional Testing of PT NGFW 1.10.3 Across 156 Criteria