When configuring HTTPS, reverse proxies, Kubernetes ingress, or API gateways, you inevitably encounter .crt, .pem, and .cer files containing blocks that look like this:
-----BEGIN CERTIFICATE-----
MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/
MSQwIgYDVQQKExtEaWdpQ2VydCBTZWN1cmUgU2l0ZSBQcm8xGzAZBgNVBAMTElRl
...
-----END CERTIFICATE-----This text is not encrypted—it is merely Base64-encoded ASN.1 data conforming to the X.509 v3 standard. Anyone holding this certificate can decode it and inspect the public key, the authorized hostnames, and who signed it.
Understanding how to read an X.509 certificate helps you diagnose handshake errors, catch expired credentials before outages occur, and verify certificate chains.
Anatomy of an X.509 certificate
An X.509 certificate binds a public key to an identity (a company, website, or service) through a cryptographic signature produced by a Certificate Authority (CA).
Every X.509 v3 certificate contains the following structural sections:
| Field | Description | Example / Notes |
|---|---|---|
| Version | The X.509 format version | Almost universally v3 (value 2) |
| Serial Number | Unique positive integer assigned by the CA | 03:A4:F2:18:... (used for revocation checks) |
| Signature Algorithm | The hash and crypto algorithm used to sign the cert | SHA256withRSA, ECDSA with SHA384 |
| Issuer | The Certificate Authority that signed this cert | C=US, O=Let's Encrypt, CN=R3 |
| Validity | The valid time window (Not Before and Not After) | Certs must be within this date window |
| Subject | The identity owning the public key | CN=example.com (Common Name) |
| Subject Public Key Info | The public key itself and its parameters | RSA 2048/4096-bit or ECDSA (secp256r1) |
| Extensions | Crucial metadata and security constraints | SANs, Key Usage, Basic Constraints |
Why the Common Name (CN) is obsolete: Subject Alternative Names (SAN)
Historically, web browsers matched the domain in the URL bar against the Common Name (CN) located in the Subject field (e.g. CN=example.com).
However, the Common Name field has severe limitations: it only supports a single hostname and has arbitrary length restrictions.
RFC 6125 officially deprecated using the Common Name for HTTPS validation. Modern browsers (Chrome, Firefox, Safari) and TLS libraries exclusively check the Subject Alternative Name (SAN) extension.
A certificate's SAN extension lists all valid hostnames and IP addresses:
X509v3 Subject Alternative Name:
DNS:example.com
DNS:www.example.com
DNS:*.api.example.com
IP Address:192.0.2.1If a certificate has CN=example.com but lacks DNS:example.com in its SAN extension, modern browsers will display an ERR_CERT_COMMON_NAME_INVALID error.
Important X.509 v3 extensions
The extensions block contains the operational rules of the certificate:
1. Basic Constraints
Specifies whether the certificate belongs to a Certificate Authority (which is allowed to sign child certificates) or an End Entity (leaf certificate):
CA:FALSE: A standard server or client certificate. Cannot sign other certificates.CA:TRUE: An intermediate or root CA certificate. Often includespathlen, restricting how many intermediate levels can follow.
2. Key Usage & Extended Key Usage (EKU)
Defines what the cryptographic key can be used for:
- Digital Signature: Authorizes signing TLS handshakes.
- Key Encipherment: Used for RSA key transport.
- Server Authentication (
1.3.6.1.5.5.7.3.1): Required for HTTPS servers. - Client Authentication (
1.3.6.1.5.5.7.3.2): Used for mTLS client certificates. - Code Signing: Used for signing software executables.
If you attempt to use a certificate with only Client Authentication as an HTTPS web server certificate, TLS clients will abort the connection.
3. Subject Public Key Info (SPKI) & SPKI Pinning
The SubjectPublicKeyInfo contains the public key itself. In mobile app development, teams often use Certificate Pinning to prevent man-in-the-middle attacks.
Instead of pinning the entire certificate (which breaks whenever the certificate expires and is re-issued), developers compute an SPKI Pin:
$$\text{SPKI Pin} = \text{Base64}(\text{SHA-256}(\text{SubjectPublicKeyInfo bytes}))$$
If you renew your certificate using the exact same private key, the certificate changes but the SPKI pin remains identical, preventing app outages during renewal cycles.
The Chain of Trust
Web browsers and operating systems do not inherently know about your specific website certificate. They validate it through a Chain of Trust:
flowchart TD
Root["Root CA (Pre-installed in OS Trust Store)"]
Intermediate["Intermediate CA (e.g. Let's Encrypt R3)"]
Leaf["Leaf Certificate (Your Domain: example.com)"]
Root -->|"Signs"| Intermediate
Intermediate -->|"Signs"| Leaf- Leaf Certificate: Your domain's certificate (
example.com). - Intermediate Certificate: Issued and signed by the Root CA. Web servers must send this intermediate along with the leaf certificate in the TLS handshake.
- Root CA Certificate: Stored in your operating system's built-in Trust Store (Windows, macOS, Linux, or Android). If the chain terminates at an untrusted or missing root, the client displays an untrusted certificate error.
How to decode an X.509 certificate
Using OpenSSL in the terminal
To read a PEM-encoded certificate on Linux or macOS:
openssl x509 -in cert.pem -text -nooutTo view just the SANs and expiration date:
openssl x509 -in cert.pem -noout -dates -ext subjectAltNameDecoding in your browser
You can inspect any PEM certificate, full certificate chain, or PKCS#10 Certificate Signing Request (CSR) directly in your browser with ToolDock's Certificate Decoder.
It automatically parses the ASN.1 structure, highlights SANs, decodes expiration warnings, displays key parameters, and computes the SPKI pin—completely client-side without sending private data to any server.
To audit live domain certificates and test whether a server sends a complete intermediate chain, use the TLS/SSL Certificate Checker and the CA Compromise Checker.