Notes
Three guarantees
TLS gives three guarantees. Confidentiality: nobody on the network path can read the traffic. Integrity: nobody can change it without detection. Authentication: you are really talking to the server you meant, proved by its certificate. Encryption without authentication is useless, because an attacker in the middle could simply present their own key. And TLS protects data in transit only, not a compromised server.
- confidentiality: nobody on the path can read it
- integrity: nobody can change it unnoticed
- authentication: you are talking to the real server (its certificate proves it)
- it does NOT protect the endpoints themselves
The handshake
The TLS 1.3 handshake takes one round trip. The client says hello with supported versions and ciphers, a key share, the server name it wants, called SNI, and ALPN protocols. The server replies with its choices, its own key share, its certificate and a signature proving it holds the private key. Both sides derive the same session keys from the key shares, and the client checks the certificate. Then encrypted data flows.
- ClientHello: versions, ciphers, key share, SNI name, ALPN
- ServerHello: chosen cipher, its key share + certificate, signature
- both derive the same session keys (ECDHE)
- client verifies the cert
- 1 round trip, then data
Chain of trust
Why should the client believe a certificate? Because a certificate authority it already trusts signed it. We built this for real: a lab CA with its own key and certificate, then a key and signing request for shoprung dot test, signed by the CA. The certificate names shoprung dot test in its subject alternative names and is valid for one month. A client that trusts our CA now trusts this certificate. Browsers and operating systems ship with a list of trusted public CAs.
ca.key + ca.crt "ShopRung Lab CA" (EC P-256) shop.key + CSR → signed by CA shop.crt CN=shoprung.test SAN DNS:shoprung.test Dec 2 2026 → Jan 1 2027 client trusts CA → trusts every cert the CA signed
It works
With our CA passed to curl, the connection worked: TLS 1.3 with an AES two fifty six cipher, subject shoprung dot test, issuer our lab CA, and the host name matched the certificate's alternative name. curl also printed the expiry date, the first thing to check in any certificate incident. ShopRung answered two hundred through nginx over HTTP two.
SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 subject: CN=shoprung.test issuer: CN=ShopRung Lab CA subjectAltName: host "shoprung.test" matched expire date: Jan 1 2027 HTTP/2 200
Break it twice
Now break it. Without our CA, curl failed with unable to get local issuer certificate: it could not build a chain to anything it trusts. In production this usually means the server forgot to send the intermediate certificate. Calling the server by IP address failed differently: no alternative certificate subject name matches the target host name. Both exit with code sixty. The wrong fix is minus k, which turns off verification and with it the whole point of TLS.
without --cacert: SSL certificate problem: unable to get local issuer certificate https://127.0.0.1:8443: no alternative certificate subject name matches target host name never fix with -k in prod
Read it with openssl
openssl s client is the TLS debugging tool. Against our nginx it negotiated TLS 1.3 and verified the chain with return code zero. Forcing TLS one point two gave an ECDHE ECDSA AES cipher instead, which shows nginx allowed both versions. openssl x509 reads a certificate file's dates and names. Many teams now disable everything below TLS one point two.
default:
TLSv1.3, TLS_AES_256_GCM_
SHA384, Verify return 0
-tls1_2:
ECDHE-ECDSA-AES256-GCM-
SHA384
$ openssl x509 -noout
-dates -ext subjectAltName
< shop.crt Strict clients
One real surprise. curl and openssl accepted our lab CA, but Python three point thirteen refused it: CA cert does not include key usage extension. Newer Python versions verify strictly by default. Different clients enforce different rules, so a certificate that works in your browser can still break one service. The fix is to create internal CAs properly, with key usage and basic constraints, or to use a real internal PKI.
ssl.SSLCertVerificationError: CA cert does not include key usage extension curl and openssl: accepted Python 3.13 strict mode: rejected fix: make CAs with proper keyUsage + basicConstraints
Automate renewal
Certificates expire, so automate renewal. Let's Encrypt issues free certificates through the ACME protocol, with tools like certbot. Cloud load balancers use managed certificates, like AWS Certificate Manager. In Kubernetes, cert manager renews them. Still, monitor days until expiry for every endpoint. And for service to service security there is mutual TLS, where the client presents a certificate too; service meshes, in part ten, do this automatically.
- Let's Encrypt: free 90-day certs via ACME (certbot)
- cloud: ACM on load balancers
- Kubernetes: cert-manager renews automatically
- monitor days-to-expiry for every endpoint
- mTLS: client shows a cert too (service mesh)
Common mistakes
Mistakes. Turning verification off in production code. Serving a certificate without its intermediate. No expiry monitoring. A certificate missing the name clients actually use, often www or an internal name. Private keys committed to Git. And old TLS versions left enabled.
- curl -k / verify=False in production code
- missing intermediate cert
- no expiry monitoring
- cert without the right SAN
- private keys in Git
- TLS 1.0/1.1 still enabled
Say it like this
In the interview: during the TLS handshake the server sends its certificate chain and proves it holds the private key with a signature. The client checks the chain up to a CA it trusts, that the host name is in the subject alternative names, and that the dates are valid. Both sides derive session keys with ephemeral Diffie Hellman. Operationally, I automate renewal and alert on days to expiry.
- "In the handshake the server
- sends its certificate and signs
- with its private key. The client
- checks the chain up to a trusted
- CA, the name in the SAN, and the dates. Then both derive session
- keys with ECDHE. I automate
- renewal and alert on expiry."