Time to Read

3 minutes

How SSL (Secure Soket Layer) Works or SSL Handshake

SSL (Secure Sockets Layer) works through a series of steps, known as the SSL handshake, to establish a secure and encrypted connection between a client (such as a web browser) and a server (such as a website). Here’s a detailed explanation of how SSL works:

  1. Client Initiates Connection: The SSL handshake begins when the client (e.g., a web browser) sends a request to establish a secure connection with the server (e.g., a website).
  2. Server Responds with Certificate: Upon receiving the client’s request, the server responds by sending its SSL certificate to the client. This certificate contains the server’s public key, its identity information (e.g., domain name), and the digital signature of a trusted Certificate Authority (CA).
  3. Client Validates Certificate: The client verifies the authenticity of the server’s certificate to ensure it is issued by a trusted CA and has not been tampered with. It checks the certificate’s validity period, issuer’s identity, and the digital signature’s integrity.
  4. Client Generates Session Key: If the certificate is valid, the client generates a random session key (also known as the symmetric key) to be used for encrypting and decrypting data during the SSL session. This session key will be shared securely with the server.
  5. Client Encrypts Session Key: The client encrypts the session key using the server’s public key obtained from the server’s certificate. This ensures that only the server, possessing the corresponding private key, can decrypt the session key.
  6. Client Sends Encrypted Session Key: The client sends the encrypted session key to the server.
  7. Server Decrypts Session Key: Upon receiving the encrypted session key, the server decrypts it using its private key. This retrieves the session key, which will be used for symmetric encryption and decryption during the SSL session.
  8. Server Confirms Ready to Secure Connection: The server acknowledges that it has decrypted the session key and is ready to proceed with the secure connection.
  9. Client and Server Agree on Cipher Suite: The client and server negotiate and agree upon a mutually supported cipher suite, which includes encryption algorithms, hash functions, and other parameters for securing the communication channel.
  10. SSL Handshake Complete: With the session key established and encryption parameters agreed upon, the SSL handshake is complete. The client and server now have a secure and encrypted connection, and they can begin exchanging data securely.
  11. Data Exchange: All data exchanged between the client and server during the SSL session is encrypted using the session key. This protects the confidentiality and integrity of the data transmitted over the network.

Example with SSL handshake Diagram:

Explanation:

  1. Client Hello: The client initiates the handshake by sending a “Client Hello” message to the server, indicating supported SSL/TLS versions, cipher suites, and extensions.
  2. Server Hello, Certificate, Server Key Exchange: The server responds with a “Server Hello” message, selecting the SSL/TLS version and cipher suite. It also sends its digital certificate and, optionally, additional information for key exchange.
  3. Client Certificate (Optional): If the server requests client authentication, the client sends its digital certificate to the server.
  4. Pre-Master Secret Exchange: Both the client and server independently generate a random pre-master secret. The client encrypts it using the server’s public key and sends it to the server.
  5. Master Secret Derivation: Both parties derive a shared master secret from the exchanged pre-master secret.
  6. Finished Messages: Both the client and server send “Finished” messages to confirm the completion of the handshake process and establish the encrypted connection.
  7. Encrypted Data: With the handshake completed, the client and server can securely exchange encrypted data over the established SSL/TLS connection.

In summary, SSL works by encrypting data exchanged between a client and server, authenticating the server’s identity using digital certificates, and establishing a secure communication channel to protect against eavesdropping, tampering, and impersonation.



Discover more from Sanchit Gurukul

Subscribe to get the latest posts to your email.



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Discover more from Sanchit Gurukul

Subscribe now to keep reading and get access to the full archive.

Continue reading