Beginner · Systems and cryptography · topic 15 of 43 · 30 min
Certificates and PKI
Explanation
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.
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.
$ 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 GMTThe 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.
Root CA (in your browser's trust store)
└─ Intermediate CA (signed by the root)
└─ shop.example (signed by the intermediate)What the browser checks
- The name in the address bar matches a name in the certificate.
- Today is between Not Before and Not After.
- Every signature in the chain is valid up to a trusted root.
- 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
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.
from datetime import date
not_after = date(2026, 5, 11)
today = date(2026, 4, 20)
print((not_after - today).days, "days left")Practice (0/3 done)
Which field tells you which names a web certificate is valid for?
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.
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
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Hashing: fingerprints for dataSystems and cryptography · same module
- Windows security basicsSystems and cryptography · same module
- Careers, salaries in India and your next stepsLinux and Red Hat (RHCSA to RHCE) · Certifications and career
- Validating input and handling errors on the serverFull-Stack Development · Building the backend
- Portfolio projects that get interviewsCloud Computing (AWS, Azure, Google Cloud) · Certifications and cloud careers
- Browser, server, URL and HTTPFrontend Web Development · How the web works
Questions people ask about this
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.
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.
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.
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.
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
- This is the last topic of “Systems and cryptography”. The module exam comes next.
- Module 3 exam: Systems and cryptography · 12 questions · 25 min, without help. 5 topics of this module still to finish first.
- Then the next module, Identity and network defence. 43 topics left in the course before the final exam.