{"id":1640,"date":"2025-11-10T21:11:12","date_gmt":"2025-11-10T18:11:12","guid":{"rendered":"https:\/\/www.dchost.com\/blog\/i-stopped-worrying-about-admin-logins-protecting-panels-with-mtls-on-nginx-step%e2%80%91by%e2%80%91step\/"},"modified":"2026-11-04T03:19:58","modified_gmt":"2026-11-04T00:19:58","slug":"nginx-mtls-admin-panel","status":"publish","type":"post","link":"https:\/\/www.dchost.com\/blog\/en\/nginx-mtls-admin-panel\/","title":{"rendered":"Protect an Admin Panel with Nginx mTLS"},"content":{"rendered":"<div class=\"dchost-blog-content-wrapper\"><p>Mutual TLS adds a client-certificate check before requests reach a protected admin application. Nginx requests a certificate and proof of possession of its private key, then verifies the certificate against configured trust. This can keep unauthenticated login attempts away from the application, while the network listener remains reachable. Rate limiting, application authentication and role checks still serve separate purposes.<\/p>\n<p>This guide uses the same OpenSSL CA, certificate, CRL and Nginx workflow as its Turkish version. It targets a Linux lab with maintained OpenSSL 3.x and TLS-enabled Nginx. Example hostnames, server certificate paths and the loopback application on port 8080 must be replaced with your actual setup. Plan both issuance and revocation before requiring certificates in production.<\/p>\n<div id=\"toc_container\" role=\"navigation\" aria-label=\"Table of Contents\" data-nosnippet class=\"toc_transparent no_bullets toc_numbered toc_title_center\"><p class=\"toc_title\">\u0130\u00e7indekiler<\/p><ul class=\"toc_list\"><li><a href=\"#What_mTLS_Protects_at_an_Admin_Gateway\"><span class=\"toc_number toc_depth_1\">1.<\/span> What mTLS Protects at an Admin Gateway<\/a><\/li><li><a href=\"#Choose_the_Client_CA_and_Trust_Boundary\"><span class=\"toc_number toc_depth_1\">2.<\/span> Choose the Client CA and Trust Boundary<\/a><\/li><li><a href=\"#Create_a_Client_CA_and_Certificate_with_OpenSSL\"><span class=\"toc_number toc_depth_1\">3.<\/span> Create a Client CA and Certificate with OpenSSL<\/a><ul><li><a href=\"#Step_1_Create_an_Exclusive_Lab_Directory\"><span class=\"toc_number toc_depth_2\">3.1.<\/span> Step 1: Create an Exclusive Lab Directory<\/a><\/li><li><a href=\"#Step_2_Define_the_CA_Client_and_CRL_Profiles\"><span class=\"toc_number toc_depth_2\">3.2.<\/span> Step 2: Define the CA, Client and CRL Profiles<\/a><\/li><li><a href=\"#Step_3_Generate_the_Protected_CA_Key\"><span class=\"toc_number toc_depth_2\">3.3.<\/span> Step 3: Generate the Protected CA Key<\/a><\/li><li><a href=\"#Step_4_Generate_a_Client_Key_and_CSR\"><span class=\"toc_number toc_depth_2\">3.4.<\/span> Step 4: Generate a Client Key and CSR<\/a><\/li><li><a href=\"#Step_5_Issue_the_Certificate_and_Initial_CRL\"><span class=\"toc_number toc_depth_2\">3.5.<\/span> Step 5: Issue the Certificate and Initial CRL<\/a><\/li><li><a href=\"#Step_6_Export_the_Client_PKCS12_Package\"><span class=\"toc_number toc_depth_2\">3.6.<\/span> Step 6: Export the Client PKCS#12 Package<\/a><\/li><\/ul><\/li><li><a href=\"#Configure_Nginx_Client_Verification\"><span class=\"toc_number toc_depth_1\">4.<\/span> Configure Nginx Client Verification<\/a><ul><li><a href=\"#Dedicated_Admin_Host_with_Mandatory_Verification\"><span class=\"toc_number toc_depth_2\">4.1.<\/span> Dedicated Admin Host with Mandatory Verification<\/a><\/li><li><a href=\"#Shared_Host_with_Protected_Admin_Paths\"><span class=\"toc_number toc_depth_2\">4.2.<\/span> Shared Host with Protected Admin Paths<\/a><\/li><\/ul><\/li><li><a href=\"#Stage_the_Rollout_and_Verify_Recovery_Access\"><span class=\"toc_number toc_depth_1\">5.<\/span> Stage the Rollout and Verify Recovery Access<\/a><\/li><li><a href=\"#Move_Certificate_Operations_to_a_CA_Service\"><span class=\"toc_number toc_depth_1\">6.<\/span> Move Certificate Operations to a CA Service<\/a><\/li><li><a href=\"#Revoke_Certificates_and_Refresh_the_CRL\"><span class=\"toc_number toc_depth_1\">7.<\/span> Revoke Certificates and Refresh the CRL<\/a><\/li><li><a href=\"#Test_Accepted_and_Rejected_Requests\"><span class=\"toc_number toc_depth_1\">8.<\/span> Test Accepted and Rejected Requests<\/a><\/li><li><a href=\"#Diagnose_Certificate_and_Routing_Failures\"><span class=\"toc_number toc_depth_1\">9.<\/span> Diagnose Certificate and Routing Failures<\/a><\/li><li><a href=\"#Authorize_Specific_Certificate_Identities\"><span class=\"toc_number toc_depth_1\">10.<\/span> Authorize Specific Certificate Identities<\/a><\/li><li><a href=\"#Keep_Application_Authentication_and_Other_Controls\"><span class=\"toc_number toc_depth_1\">11.<\/span> Keep Application Authentication and Other Controls<\/a><\/li><li><a href=\"#Understand_Proxy_Termination_and_Long_Connections\"><span class=\"toc_number toc_depth_1\">12.<\/span> Understand Proxy Termination and Long Connections<\/a><\/li><li><a href=\"#Use_the_Directive_and_Certificate_References\"><span class=\"toc_number toc_depth_1\">13.<\/span> Use the Directive and Certificate References<\/a><\/li><li><a href=\"#Maintain_Keys_Trust_Files_and_Access_Records\"><span class=\"toc_number toc_depth_1\">14.<\/span> Maintain Keys, Trust Files and Access Records<\/a><\/li><li><a href=\"#Verify_the_Complete_Admin_Access_Boundary\"><span class=\"toc_number toc_depth_1\">15.<\/span> Verify the Complete Admin Access Boundary<\/a><ul><li><a href=\"#Reference_Links\"><span class=\"toc_number toc_depth_2\">15.1.<\/span> Reference Links<\/a><\/li><\/ul><\/li><\/ul><\/div>\n<h2 id=\"section-1\"><span id=\"What_mTLS_Protects_at_an_Admin_Gateway\">What mTLS Protects at an Admin Gateway<\/span><\/h2>\n<p>With ordinary HTTPS, the client verifies the server certificate and hostname. mTLS adds server-side verification of the client certificate and its private-key proof. The two directions use separate credentials and trust stores. A trusted client certificate identifies a credential; it does not automatically authorize every action or prove who is currently using the device.<\/p>\n<p>Nginx must guard every route to the admin application for this boundary to hold. Direct backend access, alternative listeners and uncovered admin APIs can bypass the intended check. Keep application login, MFA where required and least-privilege roles. Issue separate credentials per person or device so that one compromised key can be withdrawn without replacing everyone\u2019s credential.<\/p>\n<h2 id=\"section-2\"><span id=\"Choose_the_Client_CA_and_Trust_Boundary\">Choose the Client CA and Trust Boundary<\/span><\/h2>\n<p>An OpenSSL CA is useful for learning the mechanism or managing a small controlled deployment. Its operation still needs approved enrollment, protected signing keys, a consistent certificate database, reliable CRL distribution and accountable ownership. A CA service may be more suitable when device enrollment and renewal need sustained automation.<\/p>\n<p>The lab below uses a CA dedicated to client authentication. Its encrypted private key remains on the CA machine; Nginx receives only the public CA certificate and CRL. Nginx\u2019s HTTPS server certificate is separate and must be valid for the hostname and trusted by clients. Do not treat the long-lived lab root as a complete production PKI design.<\/p>\n<p>Record the user, device, serial number, expiration and permitted role for each credential. Prefer a new key on a replacement device over copying the same PKCS#12 file everywhere. Define offboarding and recovery before rollout. If production requires an offline root and intermediate issuers, redesign chain depth, revocation files and signing procedures for that hierarchy.<\/p>\n<h2 id=\"section-3\"><span id=\"Create_a_Client_CA_and_Certificate_with_OpenSSL\">Create a Client CA and Certificate with OpenSSL<\/span><\/h2>\n<h3><span id=\"Step_1_Create_an_Exclusive_Lab_Directory\">Step 1: Create an Exclusive Lab Directory<\/span><\/h3>\n<p>Run the following in a shell on the intended CA lab machine. The directory is deliberately created without <code>-p<\/code>: an existing directory causes the command to stop rather than overwrite a CA database. Continue the following CA commands in this directory. The restrictive umask protects newly created keys and state.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">set -eu\numask 077\nmtls_dir=&quot;$HOME\/mtls-ca-lab&quot;\nmkdir &quot;$mtls_dir&quot;\ncd &quot;$mtls_dir&quot;\nmkdir certs crl newcerts private\n: &gt; index.txt\nprintf &#039;1000\\n&#039; &gt; serial\nprintf &#039;1000\\n&#039; &gt; crlnumber\n<\/code><\/pre>\n<h3><span id=\"Step_2_Define_the_CA_Client_and_CRL_Profiles\">Step 2: Define the CA, Client and CRL Profiles<\/span><\/h3>\n<p>The configuration uses <code>dir = .<\/code>, so its paths are relative to the current working directory, not a shell-expanded tilde. The serial and CRL-number files are initialized before use. The root can issue only end-entity certificates under this profile; the client profile explicitly permits TLS client authentication and does not copy arbitrary CSR extensions.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">cat &gt; openssl.cnf &lt;&lt;&#039;EOF&#039;\n[ ca ]\ndefault_ca = CA_default\n\n[ CA_default ]\ndir = .\ndatabase = $dir\/index.txt\nnew_certs_dir = $dir\/newcerts\nserial = $dir\/serial\ncrlnumber = $dir\/crlnumber\nprivate_key = $dir\/private\/ca.key.pem\ncertificate = $dir\/certs\/ca.cert.pem\ndefault_md = sha256\ndefault_days = 90\ndefault_crl_days = 7\npolicy = client_policy\nunique_subject = no\ncopy_extensions = none\nx509_extensions = client_cert\ncrl_extensions = crl_ext\n\n[ client_policy ]\ncommonName = supplied\n\n[ req ]\ndistinguished_name = req_dn\nprompt = no\nx509_extensions = root_ca\n\n[ req_dn ]\nCN = Admin Client Lab CA\n\n[ root_ca ]\nbasicConstraints = critical, CA:TRUE, pathlen:0\nkeyUsage = critical, keyCertSign, cRLSign\nsubjectKeyIdentifier = hash\nauthorityKeyIdentifier = keyid:always\n\n[ client_cert ]\nbasicConstraints = critical, CA:FALSE\nkeyUsage = critical, digitalSignature\nextendedKeyUsage = clientAuth\nsubjectKeyIdentifier = hash\nauthorityKeyIdentifier = keyid:always\n\n[ crl_ext ]\nauthorityKeyIdentifier = keyid:always\nEOF\n<\/code><\/pre>\n<h3><span id=\"Step_3_Generate_the_Protected_CA_Key\">Step 3: Generate the Protected CA Key<\/span><\/h3>\n<p>The CA key-generation and signing operations ask for a passphrase. Keep the key, passphrase and consistent CA database backups under controlled access. Do not copy this private key to Nginx. A CA root certificate is public, but its fingerprint and the process that installs it as trusted material must be authenticated.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:3072 -aes-256-cbc -out private\/ca.key.pem\nopenssl req -new -x509 -config openssl.cnf -key private\/ca.key.pem -days 3650 -sha256 -out certs\/ca.cert.pem\n<\/code><\/pre>\n<h3><span id=\"Step_4_Generate_a_Client_Key_and_CSR\">Step 4: Generate a Client Key and CSR<\/span><\/h3>\n<p>This demonstration generates Alex\u2019s key locally in the protected lab directory. For production, prefer generating the private key on the intended device and sending only its CSR to the CA. Verify the enrollment request and ownership before signing; the requested subject text alone is not proof of identity.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private\/alex.key.pem\nopenssl req -new -key private\/alex.key.pem -subj &quot;\/CN=Alex Admin&quot; -out alex.csr.pem\n<\/code><\/pre>\n<h3><span id=\"Step_5_Issue_the_Certificate_and_Initial_CRL\">Step 5: Issue the Certificate and Initial CRL<\/span><\/h3>\n<p><code>openssl ca<\/code> records issuance in the database used for later revocation. Review its confirmation prompts. The first client in this fresh lab receives serial <code>1000<\/code>; read the actual serial rather than assuming it in an existing CA. Generate the initial CRL now, even though it contains no revoked certificates, so that the file exists before Nginx references it.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">openssl ca -config openssl.cnf -extensions client_cert -days 90 -notext -in alex.csr.pem -out certs\/alex.cert.pem\nopenssl ca -config openssl.cnf -gencrl -out crl\/ca.crl.pem\nopenssl verify -CAfile certs\/ca.cert.pem -purpose sslclient -crl_check -CRLfile crl\/ca.crl.pem certs\/alex.cert.pem\nopenssl x509 -in certs\/alex.cert.pem -noout -serial -dates\n<\/code><\/pre>\n<h3><span id=\"Step_6_Export_the_Client_PKCS12_Package\">Step 6: Export the Client PKCS#12 Package<\/span><\/h3>\n<p>The PKCS#12 package includes the client private key. Enter a strong export password at the terminal. Deliver the package through a restricted, time-limited secure channel and deliver the password separately through a verified channel. Keep only necessary key copies; changing the package password later does not invalidate an already copied private key.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">openssl pkcs12 -export -inkey private\/alex.key.pem -in certs\/alex.cert.pem -certfile certs\/ca.cert.pem -out alex.p12\n<\/code><\/pre>\n<p>Import the package into the browser\u2019s or platform\u2019s personal client-certificate store. Browser policy may select it automatically or offer a chooser. Importing a client credential does not require broadly trusting this CA to authenticate arbitrary websites. Browser trust in the HTTPS server certificate and Nginx trust in the client CA are separate directions.<\/p>\n<h2 id=\"section-4\"><span id=\"Configure_Nginx_Client_Verification\">Configure Nginx Client Verification<\/span><\/h2>\n<p>Prepare the public CA certificate and initial CRL on the intended Nginx server, then install them with the following commands from the directory containing those files. If the CA is another machine, securely transfer only these public files first. The CA private key stays on the CA machine. Install a separate valid server certificate for the actual hostname and ensure the backend is reachable only through authorized proxy paths.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sudo install -d -m 0755 \/etc\/nginx\/client_ca\nsudo install -m 0644 certs\/ca.cert.pem \/etc\/nginx\/client_ca\/ca.cert.pem\nsudo install -m 0644 crl\/ca.crl.pem \/etc\/nginx\/client_ca\/ca.crl.pem\n<\/code><\/pre>\n<p><code>ssl_verify_client<\/code> belongs in http or server scope, never location. A dedicated admin hostname is the simpler whole-host boundary. For a shared hostname, the certificate is still requested during TLS before the HTTP path is known; the path check happens afterward.<\/p>\n<h3><span id=\"Dedicated_Admin_Host_with_Mandatory_Verification\">Dedicated Admin Host with Mandatory Verification<\/span><\/h3>\n<pre class=\"language-nginx line-numbers\"><code class=\"language-nginx\"># Inside the existing http {} block:\nlog_format mtls &#039;$remote_addr [$time_local] &quot;$request&quot; $status &#039;\n                &#039;verify=&quot;$ssl_client_verify&quot; serial=&quot;$ssl_client_serial&quot;&#039;;\n# Inside the existing http {} block, after log_format:\nserver {\n    listen 443 ssl;\n    server_name admin.example.com;\n    ssl_certificate \/etc\/ssl\/certs\/admin-server-fullchain.pem;\n    ssl_certificate_key \/etc\/ssl\/private\/admin-server.key;\n    ssl_client_certificate \/etc\/nginx\/client_ca\/ca.cert.pem;\n    ssl_verify_depth 1;\n    ssl_crl \/etc\/nginx\/client_ca\/ca.crl.pem;\n    ssl_protocols TLSv1.2 TLSv1.3;\n    ssl_session_cache off;\n    ssl_session_tickets off;\n    access_log \/var\/log\/nginx\/admin_access.log mtls;\n    ssl_verify_client on;\n    location \/ {\n        proxy_pass http:\/\/127.0.0.1:8080;\n        proxy_set_header Host $host;\n        proxy_set_header X-Forwarded-Proto $scheme;\n        proxy_set_header X-Client-Verify $ssl_client_verify;\n        proxy_set_header X-Client-Serial $ssl_client_serial;\n    }\n}\n<\/code><\/pre>\n<p>Place these snippets inside your existing <code>http {}<\/code> block, with log_format outside server. This example directly trusts the lab root and uses verification depth 1. Session caching and tickets are disabled to make fresh-handshake revocation tests clear; assess revocation and resumption explicitly before enabling reuse. Replace the server certificate paths and use an actual loopback-only backend. All requests on this host need a valid trusted client certificate.<\/p>\n<h3><span id=\"Shared_Host_with_Protected_Admin_Paths\">Shared Host with Protected Admin Paths<\/span><\/h3>\n<p>The following is an alternative server configuration for a shared host. It uses <code>optional<\/code> at server scope, then requires verification success on both exact <code>\/admin<\/code> and the <code>\/admin\/<\/code> subtree. Public clients without certificates can reach public locations, but may receive a certificate prompt. A presented invalid certificate can still cause even a public request to fail. The server certificate must cover <code>example.com<\/code>.<\/p>\n<pre class=\"language-nginx line-numbers\"><code class=\"language-nginx\"># Alternative to the dedicated host; inside existing http {}:\nserver {\n    listen 443 ssl;\n    server_name example.com;\n    ssl_certificate \/etc\/ssl\/certs\/public-server-fullchain.pem;\n    ssl_certificate_key \/etc\/ssl\/private\/public-server.key;\n    ssl_client_certificate \/etc\/nginx\/client_ca\/ca.cert.pem;\n    ssl_verify_depth 1;\n    ssl_crl \/etc\/nginx\/client_ca\/ca.crl.pem;\n    ssl_protocols TLSv1.2 TLSv1.3;\n    ssl_session_cache off;\n    ssl_session_tickets off;\n    access_log \/var\/log\/nginx\/admin_access.log mtls;\n    ssl_verify_client optional;\n    location \/ {\n        proxy_pass http:\/\/127.0.0.1:8080;\n        proxy_set_header Host $host;\n        proxy_set_header X-Forwarded-Proto $scheme;\n        proxy_set_header X-Client-Verify $ssl_client_verify;\n        proxy_set_header X-Client-Serial $ssl_client_serial;\n    }\n    location = \/admin {\n        if ($ssl_client_verify != SUCCESS) { return 403; }\n        proxy_pass http:\/\/127.0.0.1:8080;\n        proxy_set_header Host $host;\n        proxy_set_header X-Forwarded-Proto $scheme;\n        proxy_set_header X-Client-Verify $ssl_client_verify;\n        proxy_set_header X-Client-Serial $ssl_client_serial;\n    }\n    location ^~ \/admin\/ {\n        if ($ssl_client_verify != SUCCESS) { return 403; }\n        proxy_pass http:\/\/127.0.0.1:8080;\n        proxy_set_header Host $host;\n        proxy_set_header X-Forwarded-Proto $scheme;\n        proxy_set_header X-Client-Verify $ssl_client_verify;\n        proxy_set_header X-Client-Serial $ssl_client_serial;\n    }\n}\n<\/code><\/pre>\n<p>The location-level if only returns a denial on failed verification; it does not try to renegotiate TLS. <code>^~<\/code> prevents a later regular-expression location from taking over that matched subtree. Enumerate all actual admin APIs, login routes, rewrites and alternative listeners: these two example paths do not cover every application. A map can calculate a decision, but still needs an explicit enforcement check.<\/p>\n<p>The <a href=\"http:\/\/nginx.org\/en\/docs\/http\/ngx_http_ssl_module.html#ssl_client_certificate\" rel=\"nofollow noopener\" target=\"_blank\">Nginx client-certificate directive reference<\/a> documents the allowed scopes and verification modes. Do not use <code>optional_no_ca<\/code> as trusted client authentication unless a separate verifier actually performs the required validation. If you add intermediates, review the complete trust chain, verification depth and corresponding CRLs.<\/p>\n<h2 id=\"section-5\"><span id=\"Stage_the_Rollout_and_Verify_Recovery_Access\">Stage the Rollout and Verify Recovery Access<\/span><\/h2>\n<p>Use a staging hostname to check successful access and deliberate rejection before changing production. Include a second authorized device, an untrusted certificate, a revoked certificate and no certificate. For the shared-host model, test public paths, exact \/admin, descendants and every application-specific admin entry point.<\/p>\n<p>Verify independent recovery through controlled SSH, a provider console or an appropriately secured management VPN. A public basic-auth side door weakens the intended boundary. Mandatory host-level TLS verification cannot be disabled inside a rescue location because the path is not known when TLS requests the certificate. Keep recovery on the separate controlled management channel.<\/p>\n<p>Run <code>nginx -t<\/code> before a supported service reload and check the new workers accepted the configuration. Nginx can map its internal 495\/496 certificate errors to a clear denial page, but some TLS failures occur before an HTTP response. Do not turn verification off to make an error page or health check reachable. Back up the CA key and its consistent issuance\/revocation database.<\/p>\n<h2 id=\"section-6\"><span id=\"Move_Certificate_Operations_to_a_CA_Service\">Move Certificate Operations to a CA Service<\/span><\/h2>\n<p><a href=\"https:\/\/smallstep.com\/docs\/step-ca\" rel=\"nofollow noopener\" target=\"_blank\">step-ca documentation<\/a> covers enrollment and short-lived certificate workflows. Its default passive revocation prevents renewal; it does not invalidate an already issued certificate before expiry. Active revocation and delivery of a CRL that Nginx consumes need an explicitly supported setup. A general CA-service deployment does not automatically replace the file-based revocation process shown here.<\/p>\n<h2 id=\"section-7\"><span id=\"Revoke_Certificates_and_Refresh_the_CRL\">Revoke Certificates and Refresh the CRL<\/span><\/h2>\n<p>Track expiry, replacement devices, user departures and key compromise as separate events. The example client lifetime is 90 days; choose a lifetime that fits your risk and renewal capacity. Renew before expiration, verify the new credential and update any serial-based allowlist. Do not wait for expiry after a key is lost or exposed.<\/p>\n<p>For the example of a compromised Alex key, revoke the actual certificate file in the CA database and produce a new CRL. The <code>keyCompromise<\/code> reason is specific to that event. Run CA commands on the CA machine, then securely transfer the public CRL to the Nginx machine and run its deployment commands there. No CA private key is needed on the proxy.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">cd &quot;$HOME\/mtls-ca-lab&quot;\nopenssl ca -config openssl.cnf -revoke certs\/alex.cert.pem -crl_reason keyCompromise\nopenssl ca -config openssl.cnf -gencrl -out crl\/ca.crl.pem\nopenssl crl -in crl\/ca.crl.pem -noout -lastupdate -nextupdate\nsudo install -m 0644 crl\/ca.crl.pem \/etc\/nginx\/client_ca\/ca.crl.pem.new\nsudo mv \/etc\/nginx\/client_ca\/ca.crl.pem.new \/etc\/nginx\/client_ca\/ca.crl.pem\nsudo nginx -t &amp;&amp; sudo systemctl reload nginx\n<\/code><\/pre>\n<p>Refresh and distribute the CRL before nextUpdate even if no additional certificates have been revoked. This profile uses seven days, so schedule monitored refreshes earlier. After a successful Nginx test and reload, test a new TLS connection. Existing connections, session resumption and application sessions need their own invalidation policy; a graceful reload does not instantly disconnect everyone. Generate a new device key for replacement, rather than repackaging the compromised one.<\/p>\n<h2 id=\"section-8\"><span id=\"Test_Accepted_and_Rejected_Requests\">Test Accepted and Rejected Requests<\/span><\/h2>\n<p>Run the following from the directory containing the client files, replacing the hostname. Test Alex\u2019s acceptance before revoking it, then repeat with the same files after revocation and CRL deployment to verify rejection. A request without a certificate must not reach the protected application. A valid certificate may produce a login redirect instead of 200. Test an untrusted credential too, keeping server certificate and hostname verification enabled throughout.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">curl -i https:\/\/admin.example.com\/\ncurl -i --cert certs\/alex.cert.pem --key private\/alex.key.pem https:\/\/admin.example.com\/\ncurl -i --cert-type P12 --cert alex.p12 https:\/\/admin.example.com\/\n<\/code><\/pre>\n<p>The P12 command applies to a curl TLS backend that supports loading that format; it asks for a password rather than placing it in shell history. Schannel-based curl uses certificate-store references instead. For a private server CA, supply the correct <code>--cacert<\/code> rather than <code>-k<\/code>. Correlate failures with Nginx verification and serial logs; a client-side server-trust failure alone does not prove mTLS enforcement.<\/p>\n<h2 id=\"section-9\"><span id=\"Diagnose_Certificate_and_Routing_Failures\">Diagnose Certificate and Routing Failures<\/span><\/h2>\n<p>First identify which TLS connection failed, which peer rejected the other and whether the request reached HTTP. Missing client credentials, an untrusted server, an expired CRL, an excluded serial and an application authorization failure are different causes. Preserve the actual error and selected listener instead of guessing from one HTTP code.<\/p>\n<p>A missing required client <a href=\"https:\/\/www.dchost.com\/ssl\">SSL certificate<\/a> means the expected credential was not supplied to that TLS endpoint. Check the personal certificate store, private key, browser profile, validity and clientAuth usage. A browser may select silently, so the absence of a chooser is not conclusive. Verify whether a CDN or load balancer terminates the TLS connection before Nginx.<\/p>\n<p>A verification failure can involve CA trust, chain depth, expiration, usage constraints or revocation. Inspect the actual presented chain and Nginx error log. The lab\u2019s direct root-to-client chain differs from an intermediate-CA deployment. Add only the intended trust and required chain material; broadly trusting unrelated issuers can expand who is admitted.<\/p>\n<p>If revocation appears ineffective, confirm the serial, CA database entry, new CRL contents, nextUpdate and the exact path loaded by Nginx. Confirm the reload succeeded and use a fresh connection with the revoked credential. Then check session reuse and established application\/WebSocket sessions separately. A CRL refresh does not itself close an already authorized long-running connection.<\/p>\n<p>Use <code>openssl s_client<\/code> when a handshake trace is needed, while specifying the expected hostname and proper server trust. Compare that observation with a browser and a new curl invocation. Do not infer success from a TCP connection alone or from a certificate selection dialog without checking the application result.<\/p>\n<h2 id=\"section-10\"><span id=\"Authorize_Specific_Certificate_Identities\">Authorize Specific Certificate Identities<\/span><\/h2>\n<p>Successful certificate verification authenticates a credential accepted by the trusted CA set. Authorization decides whether that credential may enter this admin application. Nginx exposes verification state and serial number; its subject and issuer DN strings use a documented format. A substring such as \u201cAdmin\u201d in a CN is not a sound authorization policy.<\/p>\n<p>For this single dedicated CA, the following literal map admits only the verified certificate with serial 1000. Confirm the real serial with openssl x509 and keep a user\/device inventory. Add the map once at http scope, then enable the illustrated if-return check in each protected location. The map alone does not enforce access.<\/p>\n<pre class=\"language-nginx line-numbers\"><code class=\"language-nginx\"># Inside the existing http {} block, for this dedicated CA only:\nmap &quot;$ssl_client_verify:$ssl_client_serial&quot; $mtls_admin {\n    default 0;\n    &quot;SUCCESS:1000&quot; 1;\n}\n# Add inside each protected location, before proxy_pass:\n# if ($mtls_admin = 0) { return 403; }\n<\/code><\/pre>\n<p>Renewal creates a new serial, so update the allowlist through an approved transition and remove obsolete authority. If multiple CAs are trusted, a serial alone is not unique; use a verified issuer-and-serial identity or a proper authorization service. Keep the CA dedicated to the intended boundary and preserve application roles. Removing a map entry still requires a successful reload and consideration of existing connections.<\/p>\n<h2 id=\"section-11\"><span id=\"Keep_Application_Authentication_and_Other_Controls\">Keep Application Authentication and Other Controls<\/span><\/h2>\n<p>Retain application authentication, MFA where appropriate, rate limits and least-privilege permissions after mTLS. Network or VPN restrictions can complement the certificate check. <code>satisfy any<\/code> combines the access\/auth modules listed in Nginx documentation; it is not a general bypass for mandatory TLS client verification and should not be presented as a certificate rollout escape hatch.<\/p>\n<p><a href=\"https:\/\/www.dchost.com\/blog\/en\/vps-ssh-hardening-without-the-drama-fido2-hardware-keys-ssh-ca-and-safe-key-rotation-step-by-step\/\">VPS SSH hardening with hardware keys and SSH certificates<\/a> covers a separate management access channel. Some operational habits, such as protected keys, clear ownership and planned rotation, apply to both. An SSH certificate is not an X.509 client certificate, and its trust configuration does not replace the Nginx mTLS setup.<\/p>\n<h2 id=\"section-12\"><span id=\"Understand_Proxy_Termination_and_Long_Connections\">Understand Proxy Termination and Long Connections<\/span><\/h2>\n<p>If a CDN or load balancer terminates client TLS, the end-user mTLS relationship ends there. The origin sees a new connection from the proxy, not the original client\u2019s handshake. Edge-verified identity needs a trusted forwarding mechanism and separately authenticated backend transport. True TLS passthrough can leave verification at Nginx, but only if the intermediary does not terminate that TLS connection.<\/p>\n<p>The proxy examples overwrite X-Client-Verify and X-Client-Serial with Nginx-derived values. The backend must accept those headers only from the trusted proxy and prevent direct untrusted access. WebSocket proxying needs its own upgrade configuration; mTLS does not configure it. HTTP\/2 and long-lived connections do not continuously recheck certificate revocation for each message, so plan how existing sessions are closed during an incident.<\/p>\n<p>HSTS directs clients to HTTPS; it does not authorize a client. Roll it out with a short initial policy and verify all affected hostnames before considering includeSubDomains or preload. Removing the header does not instantly erase browser-cached policy or preload entries. Keep this lifecycle separate from client-certificate renewal and revocation.<\/p>\n<h2 id=\"section-13\"><span id=\"Use_the_Directive_and_Certificate_References\">Use the Directive and Certificate References<\/span><\/h2>\n<p>Use the <a href=\"http:\/\/nginx.org\/en\/docs\/http\/ngx_http_ssl_module.html#ssl_client_certificate\" rel=\"nofollow noopener\" target=\"_blank\">Nginx client-certificate reference<\/a> for directive scope, trust and variables, and the <a href=\"https:\/\/www.openssl.org\/docs\/man1.1.1\/man1\/openssl-pkcs12.html\" rel=\"nofollow noopener\" target=\"_blank\">OpenSSL PKCS#12 reference<\/a> for package behavior. The linked OpenSSL page is versioned; check your maintained installed version when selecting options. A reference link does not validate an untested deployment or a mismatched platform certificate store.<\/p>\n<h2 id=\"section-14\"><span id=\"Maintain_Keys_Trust_Files_and_Access_Records\">Maintain Keys, Trust Files and Access Records<\/span><\/h2>\n<p>Monitor client and CA expiry, CRL nextUpdate, signing-key access and deployment failures. Document enrollment, device replacement, revocation and independent recovery. Protect logs as identity-related data and never log private keys or package contents. A serial identifies the issued credential; shared keys make individual attribution unreliable.<\/p>\n<p>For larger deployments, separate authenticated enrollment from policy decisions. A dedicated authorization service can map a verified issuer\/serial identity to current roles; Nginx auth_request is one integration option when the module and service are properly configured. That service must receive identity only from the trusted proxy and deny access when required validation cannot be completed.<\/p>\n<h2 id=\"section-15\"><span id=\"Verify_the_Complete_Admin_Access_Boundary\">Verify the Complete Admin Access Boundary<\/span><\/h2>\n<p>The intended result is measurable: an authorized valid certificate reaches the correct application flow, while missing, untrusted, revoked or disallowed credentials do not reach protected routes. In the shared-host model, public behavior must remain as designed. Test every relevant listener and entry point rather than treating one successful browser visit as complete verification.<\/p>\n<p>Start in the isolated lab, stage the actual route configuration, establish the initial CRL and trust files, and validate both acceptance and rejection before rollout. Assign renewal, CRL distribution and incident owners. Use the separate controlled management channel for recovery; do not keep a public bypass as part of the normal access design.<\/p>\n<p>Repeat the checks after DNS, proxy, certificate, Nginx or application-route changes. Keep old serial authority, current CRL state and established sessions visible during rotations and incidents. A reliable mTLS boundary depends on the continuing operation of issuance, authorization and revocation as well as the initial TLS configuration.<\/p>\n<hr \/>\n<h3><span id=\"Reference_Links\">Reference Links<\/span><\/h3>\n<p><a href=\"http:\/\/nginx.org\/en\/docs\/http\/ngx_http_ssl_module.html#ssl_client_certificate\" rel=\"nofollow noopener\" target=\"_blank\">Nginx client-certificate directives<\/a><br \/><a href=\"https:\/\/www.openssl.org\/docs\/man1.1.1\/man1\/openssl-pkcs12.html\" rel=\"nofollow noopener\" target=\"_blank\">OpenSSL PKCS#12 usage<\/a><br \/><a href=\"https:\/\/smallstep.com\/docs\/step-ca\" rel=\"nofollow noopener\" target=\"_blank\">step-ca overview<\/a><\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Configure client verification in the correct Nginx scope, with an explicit CA\/CRL workflow, serial allowlist, controlled distribution and acceptance tests.<\/p>\n","protected":false},"author":1,"featured_media":8105,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[184],"tags":[],"class_list":["post-1640","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/1640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/comments?post=1640"}],"version-history":[{"count":1,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/1640\/revisions"}],"predecessor-version":[{"id":8107,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/1640\/revisions\/8107"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media\/8105"}],"wp:attachment":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media?parent=1640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/categories?post=1640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/tags?post=1640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}