Last modified: May 2, 2017
TLS is the web's standard for securely communicating over a network connection. With TLS, web clients can trust that information being shared over a network is both encrypted and secured. While most developers understand the importance of TLS, understanding exactly how TLS protects your network deserves a deeper dive. In this article, we discuss how TLS "handshakes" initiate trusted communication between clients and servers.
When web browsers (clients) access a web server over HTTPS, an initial handshake occurs between the server and the client. This handshake verifies the identity of the server and dictates what encryption method / ciphers will be used to encrypt data being sent over the network. After the handshake takes place, the browser is free to send and receive encrypted data to the server.
There are six major steps to these handshakes. Each step is listed below with supplemental detail.
The browser (client) connects to the server and requests a secure connection. It tells the server which encryption methods it supports.
After receiving the client's request for a secure connection, the server analyzes the encryption methods and ciphers (a method of encrypting text) available to the client and chooses the best fit. It then tells the client which encryption method it will be using for the secured communication.
At this point, the server sends the client a digital certificate which verifies the server's identity. This certificate includes information about the server such as the server name, it's certificate authority (more on this later) and a public encryption key.
After receiving the server's digital certificate, the client validates the certificate to ensure it's communicating with a trusted source.
Once the client trusts the server it's talking to, it uses the server's provided public key to generate an encrypted session key. It then sends this encrypted key back to the server.
After receiving the client's encrypted key, the server uses it's own private key to decrypt the session key. This validates a secure connection as only the server has access to its private key (which is needed for decrypting the client produced session key).
Certificate authorities are third party institutions that verify or "sign" the certificates provided by the server. This is important because it helps protect man-in-the-middle attacks where hackers intercept and forge certificates.By having a third party validate these digital certificates, it's more difficult for hackers to create their own phony certificates and intercept connections.
While CAs make it harder for attackers to forge certificates, they aren't fail safe. What's to stop a seasoned attacker from forging the public key provided by a CA to forge the signing of the certificate itself? Although things like certificate chains protect against these more advanced attacks, CAs themselves are not a fail safe system for man-in-the-middle attacks.
Fortunately, such attacks are extremely difficult and rare. By using TLS you are keeping your connection secure (at least by todays standards). While most websites already use TLS to communicate securely, it's beneficial to know whats going on under the hood. For more information on SSL/TLS, see SSL vs TLS.