tags:

views:

539

answers:

4

Say when using https, browser makes a request to the server and server returns its certificate including public key and the CA signature.

At this point, browser will ask its CA to verify if the given public key really belongs to the server or not?

How is this verification done by the Root cert on the browser?

To give an example: Say serverX obtained a certificate from CA "rootCA". Browser has a copy of rootCA locally stored. When the browser pings serverX and it replies with its public key+signature. Now the root CA will use its private key to decrypt the signature and make sure it is really serverX?

is it how it works?

A: 

Your browser does not ask the CA to verify, instead it has a copy of the root certs locally stored, and it will use standard cryptographic procedure to verify that the cert really is valid.

This is why when you self sign a certificate your certificate is not valid, eventhough there technically is a CA to ask, you could off course copy the self signed CA to your computer and from then on it would trust your self signed certifications.

CACert.org has this same issue, it has valid certificates but since browsers don't have its root certs in their list their certificates generate warnings until the users download the root CA's and add them to their browser.

X-Istence
it is not clear to me. Say serverX obtained a certificate from CA rootCA. Browser has the rootCA cert locally stored. So when the browser pings serverX it replies with its public key+signature. The root CA will use its private key to decrypt the signature and make sure it is really serverX?
Sesh
No, what it checks it the signature, I can sign something with my private key that validates against my public key. So the root CA that is locally stored is actually the public part of the CA. So if the remote server sends a certificate it will have a certain signature, that signature can then be
X-Istence
mathematically computed against the public part of the CA to verify that the private part of the CA actually signed the cert in and of itself.
X-Istence
+1  A: 

Certs are based on using an asymmetric encryption like RSA. You have two keys, conventionally called the private and public keys. Something you encrypt with the private key can only be decrypted using the public key. (And, actually, vice versa.)

You can think of the cert as being like a passport or drivers license: it's a credential that says "this is who I am; you can trust it because it was given to me by someone (like Verisign) you trust." This is done with a "signature", which can be computed using the certificate authority's public key. If the data is what the CA got originally, you can verify the cert.

The cert contains identifying information about the owner of the cert. When you receive it, you use the combination of the key you know from your trusted authority to confirm that the certificate you received is valid, and that you can therefore infer you trust the person who issued the cert.

Charlie Martin
Signature of a server should be pretty easy to obtain: just send a https request to it. What if a serverY obtains signature of serverX in this way - can it not impersonate serverX?
Sesh
No, when your browser connects it uses a unique start (diffie hellman key exchange), unless ServerY has the private key for your certificate that is used to compute the public key based on what the browser sends you, it is unable to impersonate serverX.
X-Istence
Sesh, what it *can* do under certain conditions is what's called an "interposer" or "man in the middle" attack. That lets it play client to the server, server to the client, and intercept all. There are protections against this. Google "man in the middle" and SSL for details.
Charlie Martin
+1  A: 

The server certificate is signed with the private key of the CA. The browser uses the public key of the CA to verify the signature. There is no direct communication between browser and CA.

The important point is that the browser ships with the public CA key. In Firefox see Tools->Options->Advanced->Encryption->ViewCertificates->Authorities. So the browser knows beforehand all CAs it can trust.

If you don't understand this, look up the basics of Asymmetric Cryptography and Digital Signatures.

+5  A: 

Your server has a certificate, consisting of a private and a public key. The server never gives out the private key of course, but everyone may get the public key. The public key is embedded within a certificate container format. This format contains the IP address or domain name of the server, the owner of this IP address/domain name, an e-mail address of the owner, etc.

The whole thing is signed by a trusted authority. The trusted authority, aka certificate authority (CA) also has a private/public key pair. You give them your certificate, they verify that the information in the container are correct and sign the it by their private key, only they have access to.

The public key of the CA is installed on the user system by default, most well known CAs are included already in the default installation of your favorite OS or browser.

When now a user connects to your server, your server uses the private key to sign some data, packs that signed data together with its public key and sends everything to the client.

What can the client now do? First of all, it can use the public key it just got sent to verify the signed data. Since only the owner of the private key is able to sign the data correctly in such a way that the public key can verify the signature, it knows that whoever signed this piece of data, this person is owning the private key to the received public key. So far so well. But what stops a hacker to intercept the packet, replace the signed data with data he signed using a different certificate and also replace the public key with his public key? Nothing.

That's why after the signed data has been verified (or before it is verified) the client verifies that the received public key has a valid CA signature. Using the already installed public CA key, it verifies that the received public key has been signed by a known CA. Otherwise it is rejected (as a hacker may have replaced it on the way).

Last but not least, it checks the information within the public key container. Does the IP address or domain name really match the IP address or domain name of the server the client is currently talking to? If not, something is fishy!

People may ask: What stops a hacker from just creating his own keypair and just putting your domain name or IP address into the cert? Easy: If he does that, no CA will sign his key. To get a CA signature, you must prove that you are really the owner of this IP address or domain name. The hacker is not, he cannot prove that, he won't get a signature. So this won't work.

Okay, how about the hacker registers his own domain, create a certificate for that, and have that signed by a CA? This works, he will get it CA signed, it's his domain, no problem. However he cannot use this when hacking your connection. If he uses this certificate, the browser will immediately see that the signed public key is for domain example.net, but it is currently talking to example.com, not the same domain, thus something is fishy again.

Mecki