Skip to content

Beginner · Systems and cryptography · topic 15 of 43 · 30 min

Certificates and PKI

Explanation

A digital certificate is an ID card for a website, person or device: it ties a name to a public key and is signed by a certificate authority (CA). PKI (public key infrastructure) is the whole system of CAs, certificates and checks that lets your browser trust a site it has never seen. Browsers check the name, the dates and the chain of signatures.

The problem certificates solve

Asymmetric encryption needs you to know someone's public key. But if a website just sends you "here is my public key", how do you know it is really your bank and not an attacker in the middle? You need someone you already trust to vouch for it. That is a certificate.

Think of it like this: A certificate is like a passport. It shows a name and a photo (the public key), and it is issued and stamped by an authority everyone trusts (the government, or here a certificate authority). Border staff check the stamp, the name and the expiry date, not whether the person looks honest.

What is inside a certificate

Web certificates follow a standard called X.509. Important fields:

  • Subject and Subject Alternative Names (SAN): the names the certificate is valid for, like shop.example and www.shop.example. A wildcard like *.shop.example covers one level of sub-domain.
  • Issuer: the CA that signed it.
  • Validity: Not Before and Not After dates.
  • Public key: the key that belongs to the subject.
  • Signature: the issuer's digital signature over all of the above.
bash
$ openssl s_client -connect shop.example:443 -servername shop.example </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -dates
subject=CN = shop.example
issuer=C = US, O = Let's Encrypt, CN = R11
notBefore=Feb 10 00:00:00 2026 GMT
notAfter=May 11 23:59:59 2026 GMT
Reading a site's certificate with openssl. You can also click the padlock in the browser.

The chain of trust

Your operating system and browser ship with a list of trusted root CAs. Roots rarely sign website certificates directly. Instead: the root signs an intermediate CA, and the intermediate signs the website (leaf) certificate. The browser checks each signature up the chain until it reaches a root it trusts.

output
Root CA            (in your browser's trust store)
  └─ Intermediate CA (signed by the root)
       └─ shop.example (signed by the intermediate)
A certificate chain.

What the browser checks

  1. The name in the address bar matches a name in the certificate.
  2. Today is between Not Before and Not After.
  3. Every signature in the chain is valid up to a trusted root.
  4. The certificate has not been revoked (cancelled early, for example after a private key leak).

If any check fails, the browser shows a full-page warning. Training people to click through those warnings is dangerous.

Certificates are getting shorter

Let's Encrypt, a free CA, has issued 90-day certificates for years, is moving to even shorter ones, and expects automatic renewal. The industry body for browsers and CAs has agreed to cut the maximum lifetime of public website certificates in steps, starting in 2026, so automation is now essential. Expired certificates are one of the most common causes of outages.

PKI in India

Under the IT Act, the Controller of Certifying Authorities (CCA) licenses Certifying Authorities that issue Digital Signature Certificates (DSC) to people and companies. DSCs are used for company filings, income tax and GST, and tenders. Aadhaar-based eSign also uses PKI behind the scenes.

Common mistakes

  • Letting certificates expire. Track expiry dates and automate renewal.
  • Self-signed certificates on public sites, which teach users to ignore warnings.
  • Leaving a private key readable on a server (chmod 600 it) or committing it to Git. If a key leaks, revoke and replace the certificate.
  • Thinking a valid certificate means the site is trustworthy. It proves the name, not the intentions.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Certificates and PKI · 1/7

Who vouches for the key?

How do you know a public key really belongs to your bank? Someone you trust must vouch for it.

Prefer a video by a teacher? Find free videos on “how SSL TLS certificates work certificate chain of trust explained” on YouTube ↗

In real life: The payment page that went down

A ticket-booking start-up forgot to renew the certificate on its payment API. At midnight it expired, every app request failed the certificate check, and bookings stopped for four hours during a big sale. Nothing was hacked, but availability was lost. The fix: automatic renewal and an alert 30 days before any certificate expires.

python
from datetime import date
not_after = date(2026, 5, 11)
today = date(2026, 4, 20)
print((not_after - today).days, "days left")
Shows 21 days left: time to renew.

Practice (0/3 done)

Task 1 · Question

Which field tells you which names a web certificate is valid for?

Task 2 · Code · Python

Write name_matches(cert_name, host) that returns True if host is covered by cert_name. Rules (lower-case both first): - exact match is True; - a wildcard "*.shop.example" matches exactly ONE extra label in front: "www.shop.example" yes, "shop.example" no, "a.b.shop.example" no.

Task 3 · Code · Python

Write expiry_status(not_after, today) where both are datetime.date objects. Return "expired" if today is after not_after, "renew soon" if 30 days or fewer are left, else "ok".

Quick quiz

Question 1

1.What does a CA do?

Question 2

2.Which certificate is stored in the browser's trust store?

Question 3

3.A certificate's private key was leaked. What should happen?

Question 4

4.Does *.shop.example cover shop.example?

Question 5

5.In India, who licenses Certifying Authorities that issue DSCs?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What does a CA do?

Answer: Signs certificates to vouch that a public key belongs to a name

A certificate authority checks control of the name and signs the certificate.

Which certificate is stored in the browser's trust store?

Answer: The root CA certificate

Browsers and operating systems ship trusted roots; chains lead back to them.

A certificate's private key was leaked. What should happen?

Answer: Revoke the certificate and issue a new one with a new key

Revocation tells clients not to trust the old certificate.

Does *.shop.example cover shop.example?

Answer: No, a wildcard covers one label in front only

The bare domain must be listed separately.

In India, who licenses Certifying Authorities that issue DSCs?

Answer: The Controller of Certifying Authorities (CCA)

The CCA, set up under the IT Act, licenses and oversees CAs.

A digital signature is created with…Related

Answer: The sender's private key

Sign with your private key; others verify with your public key.

From Symmetric and asymmetric encryption

What should NEVER be in your public Ansible GitHub repo?Related

Answer: Plain-text passwords or vault password files

Use vault, and keep password files out of Git.

From Careers, salaries in India and your next steps

Which input should be lower-cased before saving?Related

Answer: The email

Emails are compared without case, so Asha@Example.com and asha@example.com should be one account. Passwords must never be changed.

From Validating input and handling errors on the server

Which item should NEVER be committed to a public project repository?Related

Answer: Access keys or a state file containing secrets

Keys and state files with secrets must stay out of Git; use .gitignore and a remote state backend.

From Portfolio projects that get interviews

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. This is the last topic of “Systems and cryptography”. The module exam comes next.
  2. Module 3 exam: Systems and cryptography · 12 questions · 25 min, without help. 5 topics of this module still to finish first.
  3. Then the next module, Identity and network defence. 43 topics left in the course before the final exam.

← Previous: Symmetric and asymmetric encryption