TLS Handshake Explained – Java Backend Interview
Fast recall
Quick revision
Core answer
Interview-ready guide
Interview answer
At a high level, the TLS handshake negotiates protocol settings, authenticates the expected peer, and derives shared traffic keys. In a normal TLS 1.3 connection, the client sends a ClientHello containing supported versions, cipher suites, extensions, and an ephemeral key share. The server chooses compatible values and returns its own key share.
The server then sends its certificate chain and a signature that proves possession of the corresponding private key. For example, when connecting to https://api.example.com, the client verifies that the certificate is valid for api.example.com and chains to a trusted certificate authority; a valid certificate for another host is rejected.
Each side derives symmetric keys and sends a Finished message that authenticates the handshake transcript. Application data then uses authenticated symmetric encryption. A client certificate is optional and appears when mutual TLS is configured. TLS 1.2 has a different detailed message flow, so this explanation is specifically the modern TLS 1.3 shape.
TLS Handshake Explained – Java Backend Interview
Direct Answer
In a TLS 1.3 handshake, the client sends supported versions, cipher suites, extensions, and a key share. The server chooses parameters, sends its key share and certificate-based authentication messages, and both sides derive symmetric traffic keys from the key exchange. Finished messages authenticate the handshake transcript. Application data then uses fast authenticated symmetric encryption. Client certificates are optional unless mutual TLS is configured.
Code Example
# See the negotiated version, cipher, and certificate from the handshake
openssl s_client -connect example.com:443 -tls1_3 </dev/null
# ---> shows: Protocol: TLSv1.3, Cipher: TLS_AES_256_GCM_SHA384, peer certificate, etc.
// In Java, the handshake runs transparently when you open an HTTPS connection
var client = java.net.http.HttpClient.newHttpClient(); // negotiates TLS automatically
var req = java.net.http.HttpRequest.newBuilder(java.net.URI.create("https://example.com")).build();
// The first request triggers ClientHello/ServerHello/key exchange under the hood.
client.send(req, java.net.http.HttpResponse.BodyHandlers.ofString());
You rarely code the handshake yourself — the TLS stack performs it before your first byte of data.
Check your understanding
Answer these without looking back at the article.
- Why does TLS switch from asymmetric to symmetric encryption after the handshake?
- What exactly does the client check when it verifies the server's certificate?
- How did TLS 1.3 make the handshake faster?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.