I have a high level question about public key authentication in SSL (doing a school project on openSSL). Anyway, as I understand it, this is basically how SSL works..
Server creates private key using RSA or DSA. Uses private key to create public key and adds public key to its certificate. Certificate is self signed or sent to a certificate authority to be digitally signed.
When a client wishes to connect to the server, it requests the certificate, checks to see if its trusted, then encrypts its message using the certificates public key. The message is sent to the server and decrypted using the private key.
Here is where my question comes in. How does the server securely respond? The public key is public so if it encrypts with the private key and expects the client to decrypt using the public key, someone in the middle could decrypt as well... the only solution I could see is if the roles reverse and the client becomes the server, and vise versa.
Anyone have some guidance here? I would appreciate it!