This question already has an answer here:
- How does SSL/TLS work? 3 answers
I'm trying to understand how SSL/TLS certificates work, but I'm missing something. I have obtained my current understanding from this website: http://www.moserware.com/2009/06/first-few-milliseconds-of-https.html.
I've also seen this post: How do the processes for digital certificates, signatures and ssl work?
After reviewing both links for the nth time, the real mystery for me surrounds how the client verifies the server's certificate.
Here's my understanding of the steps:
1. Certificate Authority (CA) gives an encrypted root certificate to a server. 2.a. Server gives client a locally encrypted certificate and a public key. 2.b. Server gives client a root certificate which is decrypted with the public key already on the client's computer. 3. Client uses public keys to decrypt certificates. 4. Certificates contains information that satisfies client of servers authenticity.
I'm probably missing some critical information at each step, and probably also missing steps here. Assume I am the client. Here are my questions:
Q0. How do I (the client) know that I should use the given public key to decrypt the certificate? In other words, if an imposter can obtain a decrypted certificate (which--can't anyone who visits the server get these?); can the imposter encrypt the certificate with his own private key, and give me a new public key?
In this case, I think I should be able to decrypt the certificate. The clear text check may simply not work. But, can the imposter edit the clear-text to make my browser happy?
Q1. What if an imposter simply forwarded me the encrypted certificate? I would decrypt it with a real public key. There's probably something in my step 4 that I'm missing.
In this case, again the clear-text certificate must have some info that reveals it is bad. What is this info?
Q2. Is there clear text information in the decrypted certificate validates that I (the client) am connected to the server I want to connect to? I'm sure the certificate should say something like "from stackoverflow.com". Since this is done by a computer, I assume there are many comparisons done?
Q2.a How do I (the client) know that I have the correct certificate? For example, if stackoverflow.com sent me a certificate for Amazon.com, how would the browser detect a problem if (for malicious reasons) the certificate decrypted?