How does an SSL handshake work?
Answer
SSL handshake is a process that establishes a secure connection between a client and a server.
- The client sends a Client Hello message to the server, which includes the client's version of the SSL/TLS protocol, a list of the cryptographic algorithms supported by the client, and a random value.
- The server responds with a Server Hello message, which includes the server's version of the SSL/TLS protocol, a random value, and a session ID.
- The server sends a Certificate message, which contains the server's certificate.
- The server sends a Server Hello Done message, which indicates that the server is done sending messages for the Server Hello phase.
- The client sends a Client Key Exchange message, which contains the client's public key.
- The client sends a Change Cipher Spec message, which notifies the server that the client is about to send a message encrypted with the new cipher spec.
- The client sends an Encrypted Handshake Message, which contains the pre-master secret encrypted with the server's public key.
- The server sends a Change Cipher Spec message, which notifies the client that the server is about to send a message encrypted with the new cipher spec.
- The server sends an Encrypted Handshake Message, which contains the pre-master secret encrypted with the client's public key.
- The client and server can now exchange application data.