Let us discuss the basics of Public key and Private Key encryption mechanism
The Public key can be issued to any interested party and the Private key is held absolutely privately: client’s private key by the client and the server’s private key by the server and It is not shared with anyone. It is impossible to deduce what the private key is, from the public key (or vice versa). You can encrypt the plain text using the public key but then you will need a matching private key to decrypt the message.
(1)When the client requests some confidential resource from the server,
(2) the server responds it by sending its public key to the client.
(3) Now the client sends its own public key to the server,in the encrypted form using the server’s public key.Only the server can decrypt the enciphered message since it has got its matching private key.
(4)Then the server can encrypt the confidential resource using client’s public key and transmit it to the client.
Now the resource can pass through the insecure medium of the Internet in the comfortable knowledge that nobody can decrypt it – except the intended client, using its private key.
source : Study Guide – D. Bridgewater