Say Alice wants to open up an HTTPS connection to Bob through a proxy named Earl.
What prevents Earl from reading alices request, opening a connection pretending to be bob, and then opening a https connection with bob pretending to be Alice , and snooping on the traffic as it passes through ?
Your browser validates the public key provided against a trusted certificate authority.
The proxy won’t have the private key of the server therefore the proxy can’t read your traffic.
Your browser will warn you about invalid certificates if the proxy tries.