What TLS and PKI are and how they work
TLS is a protocol that protects a connection over an untrusted network: it encrypts data, detects tampering and uses a certificate to check that the server is who it claims to be. PKI, the public key infrastructure, is where that certificate comes from; without it, authentication does not work.
Websites and almost all protected traffic run on TLS: HTTPS is HTTP inside TLS, and mail, service-to-service traffic and client applications work the same way. Once you understand the handshake and certificates, it is much quicker to find the cause when a connection drops with a cryptic error.
What TLS protects
Once the handshake is done, a connection gives you three properties: confidentiality, because only the two endpoints can see the data; integrity, because tampering with records is detected; and authentication, because the server proves its name with a certificate and, with mutual authentication (mTLS), the client proves its own.
TLS does not know what it protects: HTTP, SMTP, IMAP and other application protocols run inside it. All it needs from the transport is a reliable byte stream, usually TCP. QUIC, the transport for HTTP/3, combines transport and TLS 1.3 in one protocol over UDP, so for HTTP/3 TLS runs inside QUIC.
The diagram below shows where TLS sits in the stack and how it is built: the handshake negotiates keys and checks the certificate, while the record protocol splits data into records and encrypts each one with its own keys.
SSL is the old name of the protocol. SSL 2, SSL 3 and the first TLS versions, 1.0 and 1.1, are prohibited by current standards, so calling TLS “SSL” confuses it with protocols that must not be enabled. The current versions are TLS 1.3 and, for compatibility, TLS 1.2.
What PKI is
PKI (public key infrastructure) answers the question of why a client trusts a server it has never seen. The server presents an X.509 certificate, a document in which a certificate authority (CA) has signed the link between a site name and a public key. The client verifies the signature along the chain up to a root certificate in its trust store, and so confirms that the key really belongs to that name.
In the PKI model from RFC 5280, the participants are the certificate holder, the certificate authority, which signs certificates and tracks their revocation, and the repository they are fetched from. On the internet, the server itself hands out certificates during the handshake, and Certificate Transparency logs record what public CAs issue; the full circle of trust is covered in “Certificate chains”.
A public CA such as Let’s Encrypt issues a certificate after domain validation, and issuance and renewal are automated by the ACME protocol, covered in “ACME and Let’s Encrypt”. Inside a company, you can run your own CA for services and client certificates.
How TLS 1.3 differs from TLS 1.2
TLS 1.3 is the current version of the protocol: the handshake is shorter, obsolete cryptography is removed and almost the whole handshake is encrypted. TLS 1.2 is still supported for older clients, but configuring it securely is manual work (see “Security: recommended configuration”).
| Feature | TLS 1.3 | TLS 1.2 |
|---|---|---|
| Handshake | one round trip before data | two round trips |
| Key exchange | ephemeral groups or PSK | determined by the cipher suite |
| Cipher suites | fixed list of AEAD suites | configurable, including obsolete ones |
| Forward secrecy | always, except PSK without (EC)DHE | with (EC)DHE suites |
| What is encrypted | everything after ServerHello | application data; key messages are in the clear |
| Status | the main version | supported, frozen |
Forward secrecy is a property of key exchange: if the server’s long-term key leaks, past records still cannot be decrypted, because the session key is derived from ephemeral shares and then erased. In TLS 1.2 it comes with (EC)DHE suites. In TLS 1.3, (EC)DHE exchange is built into the handshake, and the only exception is PSK mode without (EC)DHE, which has no forward secrecy (RFC 9846, section 2.2).
What you need to know first
- TCP and ports: TLS runs over a reliable TCP stream, usually on port 443; see the TCP/IP and DNS reference.
- DNS: the server name ends up in the certificate and in name verification; see the TCP/IP and DNS reference.
- Cryptography at the level of concepts: public and private keys, signatures and hashes, in plain words and without the maths.
Where to go next
The handshake, message by message, is in “The TLS 1.3 and 1.2 handshakes”, the structure of a certificate is in “X.509 certificates”, and issuance and renewal are in “ACME and Let’s Encrypt”. The openssl commands for checking are collected in the cheat sheet.
Section sources
the section is written from these pages- RFC 9846: The Transport Layer Security (TLS) Protocol Version 1.3 — 1. Introductionrfc-editor.org/rfc/rfc9846.html(opens in a new tab)
- How It Worksletsencrypt.org/how-it-works/(opens in a new tab)
- RFC 5280: Internet X.509 PKI Certificate and CRL Profile — 3. Overview of Approachrfc-editor.org/rfc/rfc5280.html(opens in a new tab)
- RFC 9325: Recommendations for Secure Use of TLS and DTLSrfc-editor.org/rfc/rfc9325.html(opens in a new tab)