I have been reading about public key encryption for the past day or2 and got thinking about something, and am hoping someone here can offer some insight. anyways here it goes
Since public key encryption is based off of the person sending the info being able to get the other guys public key to perform the encryption to his data before its sent. What if the public key he is about to receive gets intercepted and changed to the hackers public key that corresponds with the hackers private key. So when the guy gets the public key to do the encryption he thinks its his friends so when he sends out his encrypted info and it gets intercepted on this bugged line the hacker can decrypt it perfectly since it was encrypted with his public key and not the other person's. Is this possible and if so is it addressed somewhere in a particular network protocol.