How curl Handles Certificate Revocation Lists

This article explains how the curl command-line tool handles Certificate Revocation Lists (CRLs) to verify the validity of SSL/TLS certificates. While curl does not automatically download CRLs during a handshake, it possesses native support for enforcing revocation checks when provided with a local CRL file, relying on its underlying SSL/TLS library to perform the validation.

Default curl Behavior

By default, curl performs standard SSL/TLS verification. It checks if the server’s certificate is expired, matches the requested hostname, and is signed by a trusted Certificate Authority (CA) found in the local CA bundle.

However, curl does not automatically fetch or check CRLs or use Online Certificate Status Protocol (OCSP) queries by default. If a certificate has been revoked by a CA before its natural expiration date, curl will still trust it unless explicitly instructed to perform a revocation check.

Native CRL Verification using --crlfile

To enforce CRL verification, curl provides a native command-line option: --crlfile.

When you use this option, you must manually provide a path to a PEM-formatted CRL file. curl passes this file directly to the underlying SSL/TLS backend (such as OpenSSL, GnuTLS, or mbedTLS) to validate the target server’s certificate.

Command Syntax

To check a server’s certificate against a local CRL file, use the following syntax:

curl --crlfile /path/to/revoked_certs.crl https://example.com

How the Verification Process Works

  1. CRL Loading: curl reads the local CRL file specified by the user.
  2. Handshake Initiation: curl initiates the TLS handshake with the destination server.
  3. Serial Number Comparison: The underlying TLS library extracts the serial number from the server’s certificate (and intermediate certificates, if applicable).
  4. Revocation Check: The library compares these serial numbers against the revoked serial numbers listed inside the PEM-formatted CRL file.
  5. Connection Verdict:
    • If the certificate’s serial number is not in the CRL, the connection succeeds.
    • If the certificate’s serial number is listed in the CRL, the TLS handshake fails immediately.

Handling Verification Failures

If curl detects a revoked certificate using the provided CRL file, it terminates the connection and returns a specific exit code to ensure security:

Important Limitations

When using curl with CRLs, keep the following native limitations in mind: