Neither symmetric or public key algorithms allow the communicating parties to be sure that they are communicating with who they think they are. At first though it might appear that the network could be relied upon to deliver packets to the correct host. Unfortunately this is difficult to ensure because the network is not normally physically secure and many implementations of protocols allow the user to program the network address. Even if this is not possible a deterred attacher could manufacture or modify the network interface hardware or software so that it has any desired address.
When two parties exchange public keys an imposter, having taken over a network address, could reply to a request for secure communication to the true host with its own public key. The other party has no way of knowing that it is not communicating with the real host.
The SSL uses certificates to solve this problem. Certificates are issued by a well known, and trusted entity. A certificate contains:
The certificate issuer makes its public key well known. This allows anyone to check the certificate by decoding the signature and comparing the result with the original information.
To check the authenticity of a system it can be asked to present its certificate and then sent some data and `challenged' to encrypt this data using its private key. The sender can then attempt to decode this data with the public key. Since only the system that the certificate was issued for knows the private key it is the only system able to correctly encode the challenge data.