TLS and Certificates
TLS is the layer that turns HTTP into HTTPS, LDAP into LDAPS and SMTP into SMTPS. Almost everything you will test travels inside TLS, and almost everything an interception tool like Burp does is sitting in the middle of it with the client’s permission. Understanding what the handshake negotiates, what a certificate says and how the client decides whether to trust it is what lets you read a certificate error, pull hostnames out of a server, and know why a mobile app refuses to go through your proxy.
Concepts
Section titled “Concepts”What TLS solves
Section titled “What TLS solves”TLS adds three guarantees to a connection that already exists (usually TCP):
- Confidentiality: someone on the network sees that there is traffic, to which IP and, almost always, to which name (SNI), but not the content.
- Integrity: if anyone changes a byte in transit, the receiver notices and drops the connection.
- Server authentication: the client checks it is talking to who the server claims to be. The client usually does not authenticate in TLS (it does so later, with a username and password or a token), except in mTLS.
What TLS does not protect: the data once decrypted at each end, the metadata (IP, size, timing), or a vulnerable application. SQLi over HTTPS is still SQLi.
Versions
Section titled “Versions”| Version | Status | What to know |
|---|---|---|
| SSL 2.0 and 3.0 | Dead | Broken; a server that accepts them is a finding |
| TLS 1.0 and 1.1 | Deprecated (RFC 8996, 2021) | Browsers no longer accept them |
| TLS 1.2 | Current | Secure if configured well (AEAD suites and ECDHE) |
| TLS 1.3 | Current, recommended | Shorter handshake, only secure suites, forward secrecy on every full handshake (PSK-only resumption and 0-RTT are the exception) |
The TLS 1.3 handshake
Section titled “The TLS 1.3 handshake”sequenceDiagram
participant C as Client
participant S as Server
C->>S: ClientHello (versions, suites, key_share, SNI = app.lab.local)
S->>C: ServerHello (chosen suite, key_share)
Note over C,S: Both derive the handshake keys (ECDHE)
S->>C: EncryptedExtensions (ALPN, etc.)
S->>C: Certificate (server chain)
S->>C: CertificateVerify (signature with its private key)
S->>C: Finished
Note over C: Validates the chain, the name and the signature
C->>S: Finished
C->>S: Encrypted application data (GET / HTTP/1.1 ...)
- The client sends a ClientHello with the versions and suites it supports, its share of the key exchange (
key_share) and the name of the site it wants (SNI). - The server answers with a ServerHello: it picks a suite and sends its share. From here on both sides have a shared key, and the rest of the handshake is already encrypted.
- The server sends the EncryptedExtensions (parameters such as ALPN, which picks HTTP/1.1 or HTTP/2), its certificate and a CertificateVerify: a signature made with the certificate’s private key that proves it holds it.
- Both finish with Finished, an authenticated digest of the whole handshake: if anyone had tampered with a message, it would not match.
All of that fits in one round trip (1-RTT). TLS 1.2 needed two, sent the certificate in the clear and allowed key exchanges without forward secrecy (static RSA). The practical consequence: in a TLS 1.3 Wireshark capture you can’t see the certificate; in a TLS 1.2 one you can.
Forward secrecy means the session keys come from an ephemeral exchange (ECDHE): even if someone steals the server’s private key tomorrow, they can’t decrypt traffic they recorded today.
Cipher suites
Section titled “Cipher suites”A suite is the bundle of algorithms being negotiated. In TLS 1.3 it only defines the symmetric cipher and the hash, for example TLS_AES_128_GCM_SHA256; the key exchange (always ephemeral) and the signature are negotiated separately. In TLS 1.2 the suite contained everything: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = ECDHE key exchange, RSA authentication, AES-128-GCM encryption and SHA-256 hash. What you look for when auditing: no suites without forward secrecy (TLS_RSA_...), no old CBC modes, no RC4, 3DES or NULL.
The X.509 certificate
Section titled “The X.509 certificate”A certificate is a signed document saying “this public key belongs to this name”. Its important fields:
| Field | What it holds | Why you care |
|---|---|---|
| Subject | Who it is issued to (CN=app.lab.local) |
Legacy; modern clients look at the SAN |
| Issuer | Who signs it (the CA) | Self-signed if Issuer = Subject |
| Subject Alternative Name (SAN) | List of valid names: DNS:app.lab.local, DNS:*.lab.local, IPs |
A source of hostnames during recon |
| Validity | notBefore and notAfter |
Expired = certificate error |
| Public key | The server’s RSA or EC key | The one that validates CertificateVerify |
| Key Usage / Extended Key Usage | What it is for (server, client, code signing) | A client certificate is not valid as a server one |
| Signature | The CA’s signature over everything above | What the client verifies |
The chain of trust
Section titled “The chain of trust”Nobody trusts the app.lab.local certificate directly. Trust goes through a chain:
- Root: the CA’s certificate, self-signed, stored in the trust store of the operating system or the browser. Mozilla ships about 150; the Windows store, more.
- Intermediate: signed by the root; it is the one that actually signs server certificates. That way the root can stay offline.
- Leaf: the server’s certificate, signed by the intermediate.
The server must send the leaf and the intermediates. If it forgets the intermediate, some clients find it on their own and others fail: the classic “it works in the browser but not in curl”.
To accept the certificate, the client checks:
- That the name it connected to appears in the SAN (a wildcard
*.lab.localcoversapp.lab.local, but notlab.localora.b.lab.local). - That it is within its validity dates.
- That the chain reaches a root in its store and every signature is correct.
- Optionally, that it has not been revoked (OCSP or CRL). In practice many clients don’t check this strictly.
SNI: several sites on one IP
Section titled “SNI: several sites on one IP”The same server can host app.lab.local, admin.lab.local and api.lab.local on the same IP and the same port 443. Since the certificate is sent before any HTTP Host header arrives, the client says in the ClientHello which name it wants: that is SNI. The server picks the certificate (and often the website) based on that name. That is why connecting to a 443 by IP usually gives you a default certificate, or a different site, from what you see with the right name.
Self-signed, public CAs and Certificate Transparency
Section titled “Self-signed, public CAs and Certificate Transparency”- Self-signed: the server signs its own certificate. It encrypts just the same but authenticates nothing: the client can’t tell it apart from one planted by an attacker. Normal for internal panels and lab machines.
- Public CA (Let’s Encrypt, DigiCert…): checks you control the domain before signing. Let’s Encrypt issues free, automated 90-day certificates, and has announced it will keep shortening that lifetime.
- Certificate Transparency (CT): for years now, every certificate a public CA issues is published in open logs. The offensive consequence: anyone can query
crt.shand see every name an organisation has requested a certificate for, includingstaging,vpnorjira-old.
In mutual TLS the server also asks the client for a certificate and validates it against its own CA. It is used between microservices, in B2B APIs and in some VPNs. If a 443 drops the handshake with a “certificate required” error, you are looking at mTLS: without a valid client certificate you won’t get past that point.
How Burp intercepts HTTPS
Section titled “How Burp intercepts HTTPS”Burp doesn’t break TLS. It runs two separate TLS connections:
- The browser connects to Burp believing it is
app.lab.local. Burp generates a certificate for that name on the fly and signs it with its own CA. - Burp opens another, real TLS connection to the server.
This only works because you installed Burp’s CA in the browser’s trust store. Without that step, the browser sees a certificate signed by an unknown CA and shows the warning. Two mechanisms stop it even then:
- Certificate pinning: the application embeds which certificate or public key it accepts for its server and ignores the system store. Common in mobile apps. On top of that, since Android 7 apps don’t trust user-installed CAs (such as Burp’s) by default. Between the two, an app may not work through your proxy even though the browser on the same phone does.
- HSTS: the server tells the browser “with me, HTTPS only, and don’t let the user click through certificate errors”. It doesn’t stop Burp (its CA is trusted), but it does stop any certificate that isn’t.
In practice
Section titled “In practice”Connect and view the certificate and the negotiation:
openssl s_client -connect 10.10.10.20:443 -servername app.lab.local </dev/null# depth=0 CN = app.lab.local <- leaf# verify error:num=18:self-signed certificate <- self-signed: normal in a lab# ---# Certificate chain# 0 s:CN = app.lab.local# i:CN = app.lab.local <- Issuer = Subject: self-signed# ---# New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384 <- negotiated version and suite# Verify return code: 18 (self-signed certificate)The </dev/null closes the connection as soon as the handshake ends. Current OpenSSL versions send SNI automatically when -connect uses a name; -servername is essential when you connect by IP or want to ask for a different name, and without SNI you may get the default certificate instead of the one for that site.
Read the certificate fields that matter:
openssl s_client -connect 10.10.10.20:443 -servername app.lab.local </dev/null 2>/dev/null \ | openssl x509 -noout -subject -issuer -dates -ext subjectAltName# subject=CN = app.lab.local# issuer=CN = app.lab.local# notBefore=Oct 1 09:12:44 2026 GMT# notAfter=Oct 1 09:12:44 2027 GMT# X509v3 Subject Alternative Name:# DNS:app.lab.local, DNS:admin.lab.local, DNS:dev-api.lab.local <- new namesThose SAN names go straight into /etc/hosts so you can test each one as a vhost. openssl x509 -noout -text prints the whole certificate, with the key, the usages and the extensions.
See the handshake from the client side:
curl -kv https://app.lab.local/ 2>&1 | grep -E '^\* (SSL|TLS|ALPN|Server certificate| subject| issuer| expire)'# * TLSv1.3 (OUT), TLS handshake, Client hello (1):# * TLSv1.3 (IN), TLS handshake, Server hello (2):# * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384# * ALPN: server accepted h2# * Server certificate:# * subject: CN=app.lab.localIf the certificate isn’t trusted, curl stops with SSL certificate problem. With -k it ignores it (fine in a lab; never in a production script).
Audit from nmap:
nmap -p 443 --script ssl-cert,ssl-enum-ciphers 10.10.10.20# | ssl-cert: Subject: commonName=app.lab.local# | Subject Alternative Name: DNS:app.lab.local, DNS:admin.lab.local# | ssl-enum-ciphers:# | TLSv1.2:# | ciphers:# | TLS_RSA_WITH_AES_128_CBC_SHA (rsa 2048) - A <- no forward secrecy# | TLSv1.3: ...# |_ least strength: AFor a full configuration audit (versions, suites, known vulnerabilities, chain) the reference tool is testssl.sh.
Search Certificate Transparency for names (a target with a public presence, and in scope):
curl -s 'https://crt.sh/?q=%25.authorized-example.com&output=json' | jq -r '.[].name_value' | sort -uNext offensive step
Section titled “Next offensive step”- Audit weak TLS configurations and understand the historical attacks: TLS/SSL.
- Broken certificate validation in clients and applications: PKI.
- Subdomains from Certificate Transparency: subdomains.
- Intercept and modify HTTPS with the proxy: Burp Suite.
- Bypass pinning in mobile apps: SSL pinning on mobile.
Cheat sheet
Section titled “Cheat sheet”| Concept | What to remember |
|---|---|
| TLS | Confidentiality, integrity and server authentication. It doesn’t fix the application |
| TLS 1.3 | 1-RTT, encrypted certificate, forward secrecy on full handshakes (not PSK-only resumption or 0-RTT) |
| TLS 1.0/1.1, SSL | Deprecated: a finding if accepted |
| Forward secrecy | Stealing the private key later doesn’t decrypt what was recorded before |
| SAN | The list of valid names. A source of vhosts during recon |
| Chain | Leaf → intermediate → root in the store. Missing intermediate, odd failures |
| Wildcard | *.lab.local covers a single level |
| SNI | The name goes in the ClientHello: it picks the certificate and the site |
| Self-signed | Encrypts but doesn’t authenticate |
| CT / crt.sh | Every public certificate for a domain, in plain view |
| mTLS | The server also demands a certificate from the client |
| Burp | Two TLS connections; works because you trust its CA |
| Pinning | The app only accepts its own certificate: breaks interception |
openssl s_client -servername |
See the certificate and negotiation with SNI |
Review questions
Section titled “Review questions”-
Why can’t you see the server certificate in a TLS 1.3 capture, while you can in a TLS 1.2 one?
Answer
In TLS 1.3 the handshake keys are derived right after the ServerHello, so the certificate already travels encrypted. In TLS 1.2 the certificate was sent before any keys existed and travelled in the clear.
-
What does forward secrecy mean, and which TLS 1.2 suites lack it?
Answer
That session keys come from an ephemeral exchange (ECDHE/DHE), so stealing the server’s private key later doesn’t let you decrypt recorded sessions. The
TLS_RSA_WITH_...suites (static RSA key exchange) lack it. -
You connect to a 443 by IP and the certificate says
CN=default. With the hostname you get another certificate and another site. What is going on?Answer
The server picks the certificate (and site) based on SNI. Without a name there is no SNI, or it matches nothing, so you get the default certificate. You need to use the name, for example with
-servernameinopensslor by adding it to/etc/hosts. -
A lab machine’s certificate has
DNS:portal.lab.local, DNS:dev-portal.lab.localin its SAN. What do you do with that?Answer
Add both names to
/etc/hostspointing to the machine’s IP and test each one as a vhost:dev-portalmay be a different, less protected application. -
Does
*.lab.localcoverapi.dev.lab.local? What aboutlab.local?Answer
Neither. The wildcard replaces exactly one label of the name: it covers
api.lab.local, but neither a deeper level nor the bare domain. -
Why can Burp read your HTTPS without breaking TLS, and why does a mobile app with pinning still fail even if you install Burp’s CA on the phone?
Answer
Burp terminates the browser’s connection with a certificate signed by its CA, which you made the browser trust, and opens another real TLS connection to the server. An app with pinning doesn’t use the system trust store: it compares the certificate or key with the ones it has embedded, so it rejects Burp’s.
-
A site loads fine in the browser, but
curlsaysunable to get local issuer certificate. Most likely cause?Answer
The server isn’t sending the intermediate certificate. The browser fetches it on its own (or has it cached) and
curldoesn’t, so it can’t build the chain up to a trusted root.
References
Section titled “References”- RFC 8446 — The Transport Layer Security (TLS) Protocol Version 1.3
- RFC 5280 — X.509 Public Key Infrastructure Certificate and CRL Profile
- RFC 8996 — Deprecating TLS 1.0 and TLS 1.1
- Mozilla — Server Side TLS / SSL Configuration Generator
- OpenSSL —
s_client·x509 - crt.sh — Certificate Transparency search
- testssl.sh