<!-- https://pkizerotohero.com/topics/tls/ | Markdown mirror of the HTML page | PKI Zero to Hero, by Duyutech BV -->

> How HTTPS protects a connection: shared keys, key exchange, the TLS 1.3 handshake and server setup. Chapters, guides and fixes in one place.

Source: https://pkizerotohero.com/topics/tls/

Topic

# TLS and HTTPS

TLS is the protocol behind HTTPS. In TLS 1.3 both sides agree a fresh secret with ephemeral key exchange (ECDHE), the server proves who it is by signing the handshake with its certificate's key, and fast symmetric encryption then protects the data.

This hub starts with the ideas underneath (shared keys and key exchange), then covers the handshake, server configuration and the protocol errors you see when the two sides cannot agree.

## Understand it: handbook chapters

Plain words first, then the real mechanism, what it looks like at work and why it matters.

Chapter 15

### [The TLS 1.3 handshake](https://pkizerotohero.com/handbook/tls-handshake/)

In one round trip, client and server agree fresh keys with ECDHE, the server proves it holds the certificate's key by signing the handshake, and both confirm nothing was altered.

- Developer
- IT ops
- Expert

Chapter 1

### [Symmetric encryption: one shared key](https://pkizerotohero.com/handbook/symmetric-encryption/)

Symmetric encryption scrambles data with one secret key, and only someone who holds that same key can turn the scrambled data back into readable text.

- Beginner
- Developer
- IT ops

Chapter 2

### [The key-distribution problem](https://pkizerotohero.com/handbook/key-distribution/)

A shared secret key must reach each partner without anyone else seeing it, and every pair needs its own key, so sharing secret keys does not scale.

- Beginner
- Leader
- IT ops

Chapter 4

### [Key exchange and hybrid encryption](https://pkizerotohero.com/handbook/key-exchange/)

Two parties can agree a shared secret over an open network without ever sending it, then derive fast symmetric keys from it to protect the actual data.

- Developer
- IT ops
- Beginner

Chapter 23

### [Both sides show ID: mutual TLS](https://pkizerotohero.com/handbook/mutual-tls/)

In mutual TLS the client also proves who it is, with a certificate and a signature from its private key, so both ends are authenticated before any data flows.

- IT ops
- Developer
- Expert

## Do it: how-to guides

Step-by-step, with real commands and a way to check it worked.

### [How to configure TLS securely (versions, ciphers, HSTS)](https://pkizerotohero.com/guides/tls-configuration/)

You will have a web server that offers only TLS 1.2 and 1.3 with forward-secret ciphers, staples OCSP only where it still applies, sends HSTS safely, and passes testing.

- nginx
- Apache
- Linux
- Windows

### [How to install a certificate in nginx](https://pkizerotohero.com/guides/install-certificate-nginx/)

nginx serves your certificate and its full chain on port 443, with a key that matches, and you have proved it from the outside with OpenSSL and curl.

- Linux
- nginx

### [How to install a certificate in Apache httpd](https://pkizerotohero.com/guides/install-certificate-apache/)

Apache httpd serves your certificate with its full chain from one SSLCertificateFile, with a matching key, and you have proved it from outside.

- Linux
- Apache

### [How to install a certificate in IIS](https://pkizerotohero.com/guides/install-certificate-iis/)

IIS serves your certificate with its private key and intermediate on an HTTPS binding with SNI, and renewed certificates get rebound instead of silently expiring.

- Windows
- IIS

### [How to install a certificate in Tomcat and other Java servers](https://pkizerotohero.com/guides/install-certificate-tomcat/)

Tomcat, or a Spring Boot or other Java server, serves your certificate with its full chain from PEM files or a PKCS #12 keystore, verified from outside.

- Linux
- Windows
- Java
- Tomcat

### [How to check the certificate chain a server sends](https://pkizerotohero.com/guides/check-remote-certificate-chain/)

You will have listed every certificate a server sends, checked their order and links, and verified the chain with a strict client instead of a browser.

- Linux
- macOS
- Windows
- Java

### [How to set up mutual TLS (nginx and curl)](https://pkizerotohero.com/guides/mutual-tls-setup/)

You will have an nginx endpoint that accepts only clients holding a certificate from your own client CA, lets in only the clients you name, and is tested with curl.

- nginx
- Linux
- Windows

### [How to test post-quantum hybrid TLS](https://pkizerotohero.com/guides/post-quantum-tls-test/)

You will know whether your servers and network negotiate the X25519MLKEM768 hybrid key exchange, and how to read, force and troubleshoot it with OpenSSL 3.5.

- Linux
- macOS
- Windows

## Fix it: error pages

The exact messages tools and browsers print, with likely causes and safe fixes.

- [Chrome, EdgeERR\_SSL\_PROTOCOL\_ERROR](https://pkizerotohero.com/errors/chrome-err-ssl-protocol-error/)
- [Chrome, EdgeERR\_SSL\_VERSION\_OR\_CIPHER\_MISMATCH](https://pkizerotohero.com/errors/chrome-err-ssl-version-or-cipher-mismatch/)
- [JavaReceived fatal alert: handshake\_failure](https://pkizerotohero.com/errors/java-handshake-failure/)
- [curlcurl: (35) … wrong version number](https://pkizerotohero.com/errors/curl-35-ssl-connect-error/)
- [Python\[SSL: WRONG\_VERSION\_NUMBER\] wrong version number](https://pkizerotohero.com/errors/python-ssl-wrong-version-number/)
- [OpenSSLtlsv1 alert unknown ca](https://pkizerotohero.com/errors/openssl-tlsv1-alert-unknown-ca/)

## Check yours: browser tools

They run in your browser. Nothing you paste is sent anywhere.

Tool

### [Chain checker](https://pkizerotohero.com/tools/chain/)

Paste a chain and see which link is missing, expired or out of order.

Tool

### [Hostname matcher](https://pkizerotohero.com/tools/hostname/)

Test whether a name matches a certificate's SANs and wildcards.

Tool

### [Paste your error](https://pkizerotohero.com/tools/error-finder/)

Paste a certificate error from any tool and get the page that explains it.

## The big picture: crash course

Short lessons of about nine minutes each, with check questions.

- [Lesson 1: Secrets and the sharing problem](https://pkizerotohero.com/course/secrets-and-sharing/)
- [Lesson 2: Two keys](https://pkizerotohero.com/course/two-keys/)
- [Lesson 7: The handshake and its errors](https://pkizerotohero.com/course/handshake-and-errors/)
- [Lesson 10: Beyond the browser, and what comes next](https://pkizerotohero.com/course/beyond-the-browser/)

## Look it up: glossary terms

Every term in plain words, linked to its full entry.

- [AEAD (authenticated encryption)](https://pkizerotohero.com/handbook/glossary/#aead "Encryption that also protects integrity: the receiver can detect any change to the ciphertext before trusting the decrypted data.")
- [AES](https://pkizerotohero.com/handbook/glossary/#aes "The Advanced Encryption Standard: the symmetric block cipher used to encrypt most data on the internet, with 128-, 192- or 256-bit keys.")
- [Authentication tag](https://pkizerotohero.com/handbook/glossary/#authentication-tag "A short value computed with the secret key over an encrypted message, so the receiver can detect any change to it.")
- [Block cipher](https://pkizerotohero.com/handbook/glossary/#block-cipher "A symmetric cipher that encrypts fixed-size blocks of data, such as AES with 16-byte blocks.")
- [Brute force](https://pkizerotohero.com/handbook/glossary/#brute-force "Trying every possible key until one works. Long enough keys make it impossible in practice.")
- [CertificateVerify](https://pkizerotohero.com/handbook/glossary/#certificate-verify "The TLS 1.3 handshake message in which a server, or a client in mutual TLS, signs the handshake with its private key.")
- [Cipher](https://pkizerotohero.com/handbook/glossary/#cipher "An algorithm that turns readable plaintext into unreadable ciphertext with a key, and back again.")
- [Cipher suite](https://pkizerotohero.com/handbook/glossary/#cipher-suite "A named set of cryptographic algorithms that a TLS connection uses, such as TLS_AES_128_GCM_SHA256.")
- [Ciphertext](https://pkizerotohero.com/handbook/glossary/#ciphertext "Encrypted data. Without the right key it looks like random bytes and reveals nothing about the plaintext except, usually, its length.")
- [Client certificate](https://pkizerotohero.com/handbook/glossary/#client-certificate "A certificate that a client, such as a service, device or user, presents to prove its identity to a server in mutual TLS.")
- [Decryption](https://pkizerotohero.com/handbook/glossary/#decryption "Turning ciphertext back into readable plaintext with the right key.")
- [Diffie-Hellman](https://pkizerotohero.com/handbook/glossary/#diffie-hellman "A method for two parties to agree a shared secret over a public channel, without ever sending the secret itself.")
- [ECDHE](https://pkizerotohero.com/handbook/glossary/#ecdhe "Elliptic-curve Diffie-Hellman Ephemeral: the usual key exchange in TLS 1.3, agreeing a fresh secret for every connection.")
- [Encryption](https://pkizerotohero.com/handbook/glossary/#encryption "Turning readable data into ciphertext with a key, so only someone with the right key can read it.")
- [Forward secrecy](https://pkizerotohero.com/handbook/glossary/#forward-secrecy "A property of key exchange: stealing a server's long-term private key later does not let anyone decrypt past sessions.")
- [HSTS](https://pkizerotohero.com/handbook/glossary/#hsts "HTTP Strict Transport Security: a header that tells browsers to use only HTTPS for a site and to refuse certificate warnings.")
- [Hybrid encryption](https://pkizerotohero.com/handbook/glossary/#hybrid-encryption "Using public-key cryptography to agree or protect a symmetric key, and that fast symmetric key to encrypt the actual data.")
- [Key](https://pkizerotohero.com/handbook/glossary/#key "A secret or public value that controls what a cryptographic algorithm does, such as which ciphertext encryption produces.")
- [Key distribution](https://pkizerotohero.com/handbook/glossary/#key-distribution "Getting the right keys to the right people safely. With shared secret keys, it is the hard problem that public-key cryptography solves.")
- [Key distribution centre (KDC)](https://pkizerotohero.com/handbook/glossary/#key-distribution-centre "A trusted server that shares a secret key with every user and hands out session keys so two users can talk.")
- [Key exchange](https://pkizerotohero.com/handbook/glossary/#key-exchange "A protocol by which two parties agree a shared secret over an open network, so they can then use fast symmetric encryption.")
- [Mode of operation](https://pkizerotohero.com/handbook/glossary/#mode-of-operation "The rule for using a block cipher on messages longer than one block, such as GCM, CTR or CBC.")
- [Mutual TLS (mTLS)](https://pkizerotohero.com/handbook/glossary/#mutual-tls "TLS in which the client also presents a certificate and proves its private key, so both sides are authenticated.")
- [Nonce](https://pkizerotohero.com/handbook/glossary/#nonce "A number used once: a random or counter value that makes each message, request or handshake unique.")
- [Out-of-band](https://pkizerotohero.com/handbook/glossary/#out-of-band "Through a separate channel from the one you are trying to secure, such as checking a key's fingerprint by phone.")
- [Plaintext](https://pkizerotohero.com/handbook/glossary/#plaintext "The readable data before encryption or after decryption.")
- [Pre-shared key (PSK)](https://pkizerotohero.com/handbook/glossary/#pre-shared-key "A secret key that both parties received in advance, outside the protocol that uses it.")
- [Secret key](https://pkizerotohero.com/handbook/glossary/#secret-key "The single shared key in symmetric encryption, which both sides must hold and nobody else may know.")
- [Server Name Indication (SNI)](https://pkizerotohero.com/handbook/glossary/#server-name-indication "A TLS extension in which the client says which hostname it wants, so a server hosting many sites can pick the right certificate.")
- [Service mesh](https://pkizerotohero.com/handbook/glossary/#service-mesh "An infrastructure layer that handles traffic between services, typically giving each service a certificate and using mutual TLS for every call.")
- [Session key](https://pkizerotohero.com/handbook/glossary/#session-key "A symmetric key that protects one connection or session, then is thrown away.")
- [SNI](https://pkizerotohero.com/handbook/glossary/#sni "Short for Server Name Indication: the hostname a TLS client sends in its first message, so the server picks the right certificate.")
- [SPIFFE](https://pkizerotohero.com/handbook/glossary/#spiffe "Secure Production Identity Framework for Everyone: a standard for giving software workloads identities, usually as short-lived X.509 certificates.")
- [Stream cipher](https://pkizerotohero.com/handbook/glossary/#stream-cipher "A symmetric cipher that produces a stream of key-dependent bytes and combines it with the data, such as ChaCha20.")
- [SVID](https://pkizerotohero.com/handbook/glossary/#svid "SPIFFE Verifiable Identity Document: the certificate or token that proves a workload's SPIFFE ID.")
- [Symmetric encryption](https://pkizerotohero.com/handbook/glossary/#symmetric-encryption "Encryption in which the same secret key both encrypts and decrypts, such as AES.")
- [TLS](https://pkizerotohero.com/handbook/glossary/#tls "Transport Layer Security: the protocol that encrypts and authenticates connections such as HTTPS, using certificates to prove the server's identity.")
- [TLS handshake](https://pkizerotohero.com/handbook/glossary/#tls-handshake "The opening exchange of a TLS connection, in which client and server agree keys and the server proves its identity.")
- [Workload identity](https://pkizerotohero.com/handbook/glossary/#workload-identity "An identity given to a piece of running software, such as a service or job, rather than to a person or a machine.")
- [X25519](https://pkizerotohero.com/handbook/glossary/#x25519 "A fast, widely used elliptic-curve Diffie-Hellman function on Curve25519, the default key exchange in most TLS 1.3 connections.")

## Other topics

- [Certificates](https://pkizerotohero.com/topics/certificates/)
- [Chains and trust stores](https://pkizerotohero.com/topics/chains-and-trust/)
- [Lifecycle and automation](https://pkizerotohero.com/topics/lifecycle-and-automation/)
- [Revocation and transparency](https://pkizerotohero.com/topics/revocation-and-transparency/)
- [Private PKI](https://pkizerotohero.com/topics/private-pki/)
- [Hashes and signatures](https://pkizerotohero.com/topics/signing/)
- [Post-quantum cryptography](https://pkizerotohero.com/topics/post-quantum/)
