Skip to content
Lesson: CertificatesSwitch
← Security Operations

Security investigations

Certificates

Read a server certificate and understand how a client decides to trust it.

A certificate binds a name, such as www.example.com, to a public key. The server keeps the matching private key secret and proves during the TLS handshake that it holds it.

The chain of trust

A certificate is signed by a certificate authority (CA). Your system or browser keeps a store of trusted root certificates. Usually a root signs an intermediate, and the intermediate signs the server's certificate. The server should send its own certificate plus the intermediates.

A self-signed certificate is signed with its own key, so clients do not trust it unless you add it deliberately.

What the client checks

  • A valid chain to a trusted root.
  • The current time is within the validity period.
  • The requested name matches a Subject Alternative Name (SAN) entry.
  • The certificate is allowed for this use.

A wildcard such as *.example.com matches shop.example.com, but not example.com or a.b.example.com. Revocation checking also exists, and clients differ in how strictly they apply it.

Inspect a certificate

bash
$ openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -dates
subject=CN = www.example.com
issuer=C = US, O = Example CA
notBefore=Jan 10 00:00:00 2026 GMT
notAfter=Apr 10 23:59:59 2026 GMT

The values above are illustrative, and spacing differs between OpenSSL versions. -servername sends the name so a server hosting several sites picks the right certificate.

To test expiry in a script:

bash
$ openssl x509 -in server.crt -noout -checkend 1209600
Certificate will not expire

1209600 is 14 days in seconds. The exit status is non-zero if it will expire within that time.

Keep them healthy

Expired certificates are a common, avoidable outage. Automate renewal, for example with a client that speaks the ACME protocol, and still alert on expiry in case renewal fails. After renewal, the server usually needs a reload to use the new file.

Protect the private key with tight file permissions, and never put it in a repository or send it by chat. If it leaks, replace the key and have the certificate revoked.

Try it

Run the s_client command against a site you manage and note the issuer and notAfter date. The permissions in depth lab helps with protecting key files.

Check your understanding

Certificates

All 3 sections · no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.