495 SSL Certificate Error
Failed client certificate verification on nginx produces the 495 SSL Certificate Error status code.
Usage
The 495 SSL Certificate Error status code indicates the client sent an invalid SSL certificate with the HTTP request. Resolving this error requires resubmitting the request with a valid client certificate.
Common causes include expired certificates, certificates signed by an untrusted authority, and certificates with mismatched common names.
Example
A client sends a request with an expired client certificate. The nginx server records the failure as 495 SSL Certificate Error and, in the default configuration, answers the client with a 400 response carrying the built-in error page.
Request
GET /secure/api HTTP/1.1
Host: www.example.re
Response
HTTP/1.1 400 Bad Request
Server: nginx
Content-Type: text/html
Connection: close
<html>
<head><title>400 The SSL certificate error</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<center>The SSL certificate error</center>
<hr><center>nginx</center>
</body>
</html>
The nginx error log records the specific certificate verification failure:
client SSL certificate verify error: (10:certificate has expired) while reading client request headers
Configuring client certificate verification
The ssl_verify_client directive decides whether 495
arises at all, and the mode chosen changes which
failures surface.
| Mode | Behavior |
|---|---|
off |
No verification, default |
on |
Certificate required and verified |
optional |
Verified when presented |
optional_no_ca |
Verified without requiring a known CA |
Verification failures under on and optional both
produce 495. Selecting optional_no_ca accepts
certificates whose chain leads nowhere trusted, which
suits deployments passing the certificate to an
application for its own checks.
ssl_client_certificate /etc/nginx/ssl/client-ca.crt;
ssl_verify_client on;
ssl_verify_depth 2;
The ssl_verify_depth directive defaults to 1, so a
certificate signed through an intermediate rather
than directly by the trusted root fails verification
until the depth rises.
The handshake itself completes before any of this happens. nginx accepts the connection, then checks the verification result while processing the request, which is why a certificate problem produces an HTTP status rather than a TLS alert. Client-side symptoms therefore look like a normal 400 response rather than a failed connection.
error_page 495 =400 /errors/cert-invalid.html;
location = /errors/cert-invalid.html {
root /var/www;
internal;
}
The directive belongs at server or http level,
since no location is selected when the condition
arises.
How to fix
Check the nginx error log first. The log entry identifies the exact verification failure with the OpenSSL verify code and its text:
client SSL certificate verify error: (10:certificate has expired) while reading client request headers
Code 10 is an expired certificate. Codes 2, 20 and 21 (unable to get issuer certificate, unable to get local issuer certificate, unable to verify the first certificate) all point at a chain the server cannot complete.
Verify the client certificate is not expired. Check the certificate dates with:
openssl x509 -enddate -noout -in client.pem
Renew the certificate before expiry to avoid service interruptions.
Ensure the full certificate chain is included. Intermediate certificates linking the client certificate to a trusted root must be bundled in the client request. Missing intermediates most often log code 20, with 2 or 21 for other gaps in the chain.
Confirm the issuing CA is listed in the server's
ssl_client_certificate file. The file holds all
trusted CA certificates (root and intermediate) in
PEM format, concatenated, and ssl_verify_depth
has to cover the number of intermediates in the
chain, as described above.
Check key strength. OpenSSL security level 2, the default on several Linux distributions, rejects RSA keys shorter than 2048 bits, so a client certificate with a 1024-bit key fails verification on those servers regardless of its chain.
Increase the nginx error log verbosity to
info level when debugging:
error_log /var/log/nginx/error.log info;
Regenerate the client certificate if the private key is compromised or the certificate file is corrupted.
See also
- 400
- Google: HTTP status codes and network errors
- 496
- nginx ssl_module Error Processing
- HTTP status codes