Security Basics — SSH, TLS and Certificates›08 · Anatomy of a certificate

Lesson 08 of 16 · HTTPS and certificates

Anatomy of a certificate

Every term printed on a certificate, explained: subject and common name, subject alternative names (SAN) and wildcards, issuer, validity dates, serial number, public key, key usage and extended key usage, basic constraints, key identifiers and fingerprints. Then the certificate signing request (CSR) and the file formats you will meet: PEM, DER, PKCS#12/PFX.

Beginner → Practitioner
Key wordsX.509certificatesubjectcommon nameCNsubject alternative nameSANwildcardissuervaliditynotBeforenotAfterserial numberpublic keykey usageextended key usagebasic constraintsfingerprintCSRPEMDERPKCS#12PFX

A certificate is a signed statement

An X.509 certificate says: "This public key belongs to these names, for this period, for these purposes", and it is signed by an issuer (a certificate authority, lesson 9). Here is a real one, made in the lab in lesson 10:

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 68:f6:c3:62:c1:9c:9b:54:c8:38:3f:de:c6:14:08:8d:5c:e0:16:d9
        Signature Algorithm: ecdsa-with-SHA256
        Issuer: CN = Lab Root CA
        Validity
            Not Before: Nov  7 18:37:23 2026 GMT
            Not After : Feb  5 18:37:23 2027 GMT
        Subject: CN = web.lab.test
        Subject Public Key Info:
            Public Key Algorithm: id-ecPublicKey
                Public-Key: (256 bit)
        X509v3 extensions:
            X509v3 Subject Alternative Name:
                DNS:web.lab.test, DNS:www.lab.test
            X509v3 Basic Constraints:
                CA:FALSE
            X509v3 Key Usage: critical
                Digital Signature
            X509v3 Extended Key Usage:
                TLS Web Server Authentication
            X509v3 Subject Key Identifier: C4:6A:53:…
            X509v3 Authority Key Identifier: EB:CF:8A:…
    Signature Algorithm: ecdsa-with-SHA256
    Signature Value: 30:45:02:20:…

Every field, in plain words

Field Meaning
Version X.509 version; always 3 today (extensions need it)
Serial Number Unique number from the issuer; used to identify and revoke the certificate
Signature Algorithm How the issuer signed it (e.g. ECDSA or RSA with SHA-256)
Issuer Who signed it: a CA, or the subject itself if self-signed
Validity: Not Before / Not After The period it can be used. Outside it, clients reject it (lesson 12)
Subject Who it was issued to, as a distinguished name: CN (common name), and sometimes O (organisation), C (country)
CN (Common Name) Historically the hostname. Now informational only for websites
Subject Public Key Info The public key and its algorithm; the matching private key stays on the server
Subject Alternative Name (SAN) The names it is actually valid for: DNS names, IP addresses, emails, URIs
Basic Constraints CA:TRUE may sign other certificates; CA:FALSE is an end certificate (leaf)
Key Usage What the key may do: Digital Signature, Key Encipherment, Certificate Sign, CRL Sign
Extended Key Usage (EKU) Purpose: TLS Web Server Authentication (serverAuth), TLS Web Client Authentication (clientAuth, for mTLS), code signing
Subject / Authority Key Identifier IDs that link a certificate to the CA certificate that signed it; used to build the chain
CRL / OCSP / CA Issuers URLs Where to check revocation, and where to download the issuer certificate (public CAs)
Signature Value The issuer's signature over everything above
Fingerprint Not stored in the certificate: a hash of the whole certificate, used to identify it

A certificate is like a passport. Subject is your name. SAN is the list of names you're allowed to travel under. Issuer is the country that issued it. Validity is the issue and expiry dates. Serial number is the passport number. Key usage is like a visa saying what you may do there. The signature is the government stamp that makes it hard to forge.

SAN is what matters, and wildcards

  • Browsers check the hostname against the SAN list, not the CN. A certificate with the name only in the CN fails.
  • One certificate can list many names: DNS:example.com, DNS:www.example.com, DNS:api.example.com.
  • A wildcard *.example.com matches exactly one label: api.example.com ✔, example.com ✘, v2.api.example.com ✘.
  • Internal services sometimes need IP SANs (IP:10.0.0.5) if clients connect by IP.

The CSR: how you ask for a certificate

You                                          Certificate authority
generate key pair (private key stays here)
create CSR = public key + requested names,
             signed with your private key  ─► checks you control the names
                                               signs a certificate
                       certificate ◄──────────
install private key + certificate (+ chain) on the server
$ openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
    -keyout site.key -out site.csr -subj "/CN=site.example.com" \
    -addext "subjectAltName=DNS:site.example.com,DNS:www.site.example.com"
$ openssl req -in site.csr -noout -text | grep -A1 "Alternative Name"

The private key never goes to the CA. If someone asks you to email your private key to get a certificate, something is wrong.

File formats

Format Looks like Typical use
PEM (.pem, .crt, .key) Text between -----BEGIN CERTIFICATE----- lines Linux, nginx, Apache, Kubernetes
DER (.der, .cer) Binary Java, Windows, some devices
PKCS#12 (.p12, .pfx) Binary bundle of key + certificate + chain, password-protected Windows/IIS, Java keystores, importing into browsers
Chain / bundle (fullchain.pem) Several PEM certificates one after another Server certificate first, then intermediates

The extension does not reliably tell you the format; head -1 file does (PEM starts with -----BEGIN).

Recap

  • A certificate = public key + names + validity + purposes, signed by an issuer.
  • SAN decides which names it is valid for; wildcards cover one label.
  • Basic constraints, key usage and EKU limit what it can do.
  • A CSR carries your public key and names; the private key never leaves you.
  • Know PEM, DER and PKCS#12, and keep chains in the right order.

This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.