I won't describe the process of establishing an encrypted connection at this time. The client begins the transaction. For a client to authenticate a server, the server must complete a task that only it can complete, and the client must be able to verify that operation. To do that, both the client and the server use the public-key cryptography operations that I discussed in Part 1 . The server responds with the digital signature, and the client, using the public key stored in the server's certificate, verifies the server's digital signature.
Authentication is complete.
In many situations it's possible that the client and server have not been introduced previously, and therefore, the client won't have the server's certificate in its possession. If this is likely to be a common scenario, the server can return its own certificate along with the signature in its response. In this attack, a malicious third party sits between two communicating parties and, to each party, masquerades as the other party. To defend against this attack, you must verify that the supplied certificate belongs to the party to which you intend to communicate. In no event should the server be allowed to sign data it generates itself and then return both the data and the signature to the client for verification.