Certificates

How TLS Certificates Work

By KeyedNode Editorial Team · · 5 min read

When you visit a website and see a padlock in the address bar, a TLS certificate is doing quiet but important work. It lets your browser confirm that the site is the one you intended to reach, and it provides the keys that scramble your traffic so nobody on the network can read it.

TLS stands for Transport Layer Security, the protocol that replaced the older SSL. People still say "SSL certificate" out of habit, but the technology in use today is TLS. This article explains what a certificate contains, how the checking process works and what can go wrong.

The problem certificates solve

Encryption alone is not enough. Imagine you connect to what you think is your bank, and an attacker sits between you and the real site. You could set up an encrypted connection, but with the attacker, not the bank. Your data would be scrambled on the wire and perfectly readable to the person who tricked you.

So the browser needs two guarantees: the connection is private, and the other end is genuinely the site named in the address bar. Certificates provide the second guarantee by linking a domain name to a public key, with a trusted third party vouching for that link.

What is inside a certificate

A certificate is a small structured document, following the X.509 standard. Its most important fields include:

  • Subject: the domain name or names the certificate covers, such as example.com. Modern certificates list names in a field called Subject Alternative Name.
  • Public key: the key belonging to the server, used to set up encryption.
  • Issuer: the certificate authority (CA) that signed the document.
  • Validity period: the dates before which and after which the certificate must not be trusted.
  • Signature: the issuer's digital signature, proving the contents were not altered.
  • Extensions: extra details, such as what the key may be used for.

The matching private key is not in the certificate. It stays on the server and must be kept secret.

The chain of trust

Browsers and operating systems ship with a list of root certificates belonging to organizations they trust. Root CAs rarely sign website certificates directly, because their private keys are guarded extremely carefully. Instead, a root signs an intermediate certificate, and the intermediate signs the website's certificate.

This produces a chain:

  1. The website's certificate, signed by the intermediate.
  2. The intermediate certificate, signed by the root.
  3. The root certificate, already trusted by your device.

The server sends its certificate plus any intermediates. Your browser follows the signatures upward until it reaches a root it already trusts. If any link is missing, expired or invalid, the browser shows a warning.

What happens during the connection

Here is a simplified view of a TLS handshake.

  1. Hello. Your browser says which TLS versions and cipher options it supports, and names the site it wants.
  2. Certificate. The server answers with its certificate chain.
  3. Verification. The browser checks the signatures, the dates, whether the name matches the address, and whether the certificate has been revoked.
  4. Key agreement. Both sides use asymmetric cryptography to agree on a fresh shared secret. The server proves it holds the private key matching the certificate.
  5. Encrypted session. Both sides switch to fast symmetric encryption derived from that secret, and the page loads.

All of this normally takes a fraction of a second.

How a certificate is issued

A site owner follows a process like this:

  1. Generate a private key and a certificate signing request (CSR) on the server.
  2. Send the CSR to a CA.
  3. Prove control of the domain. Often the CA asks you to place a specific file on the website or add a particular DNS record.
  4. Receive the signed certificate and install it along with the intermediates.

Validation levels differ. Domain validated certificates only prove control of the domain. Organization validated and extended validation certificates involve extra checks of the legal entity, though browsers no longer display them very differently. Automated issuance, using the ACME protocol, lets servers request and renew domain validated certificates without manual work. Tools based on ACME are free and widely used.

Why certificates expire

Certificates have limited lifetimes, and the maximum has been shortened over the years. Short lifetimes reduce the time a stolen key remains useful and force operators to automate renewal. When certificates are renewed regularly, mistakes in the process show up quickly.

If a certificate expires, browsers warn visitors loudly, and many will not let them proceed easily. Expired certificates are one of the most common avoidable causes of website outages.

Revocation

Sometimes a certificate must be cancelled before its expiry, for example if the private key leaked. CAs publish revocation information through lists or through an online status service called OCSP. Revocation checking has practical weaknesses, which is another reason short lifetimes help.

Inspecting a certificate yourself

You can look at the certificate any server presents using the openssl tool.

openssl s_client -connect example.com:443 -servername example.com

Add | openssl x509 -noout -dates -subject -issuer to the end to print the validity dates, subject and issuer. Browsers show similar details when you click the padlock icon.

Common problems

  • Name mismatch. The certificate covers example.com but the visitor uses www.example.com or another name.
  • Expired certificate. Renewal failed or nobody was assigned to it.
  • Incomplete chain. The server forgot to send the intermediate certificate.
  • Untrusted issuer. A self-signed certificate was used where public trust is needed.
  • Wrong clock. A device with an incorrect date sees valid certificates as expired.

Frequently Asked Questions

Does the padlock mean a website is safe?

Not exactly. It means the connection is encrypted and the certificate matches the domain. A fraudulent site can also obtain a certificate for its own domain, so the padlock says nothing about the intentions of the site owner. Always check the address carefully.

What is a self-signed certificate?

It is a certificate signed by its own key rather than by a CA. Browsers do not trust it by default, so it triggers a warning. It can be reasonable for internal testing, where you can install it manually on the devices that need it, but it is unsuitable for public websites.

Do I need a separate certificate for every subdomain?

Not necessarily. A single certificate can list several names, and a wildcard certificate covers all subdomains at one level, such as everything under *.example.com. Which approach is better depends on how you manage your servers and how you want to limit the impact of a key compromise.

Related reading

  • PKI

    Public Key Infrastructure Explained Simply

    PKI is the system of keys, certificates and trusted authorities that lets strangers verify each other online. Here are its parts and how they fit together.

    · 5 min read