I am trying to understand if pinning a certificate essentially means pinning the CA or if they are different how so ?
2 Answers
The generic processing of a certificate goes thus:
- The client builds a certificate chain going from a trust anchor (a given certificate which is known a priori by the client) down to the server's certificate.
- The client verifies that all signatures and other information are correct along the chain (each certificate has a subject and an issuer names: its issuer name must be equal to the subject name of the previous certificates; each certificate is signed and the signature must match the public key from the previous certificate; and so on).
- The client checks that the expected server name (the one from the
https://
URL) appears where it should in the server's certificate.
Certificate pinning is equivalent to turning the server's certificate into a trust anchor with limited scope: the client stores the server's certificate, and will used it as the trust anchor when validating the server's certificate again. In the description above, this means that when coming back to the server, the client will build a chain of length 1, containing only the server's certificate itself, which the client "trusts" in that context because it remembers it exactly.
Certificate pinning can be inclusive or exclusive; the former means that the client will accept the remembered server's certificate as a trust anchor in addition to its other, "normal" trust anchors (its "root certificates"), while the latter means that the client will use only the pinned certificate as trust anchor. The overall effect of exclusive certificate pinning is that the client will accept the server's certificate only if it is bit-to-bit equal to the one it remembers; no other certificate would be deemed acceptable.
Usually, when people talk about pinning, they mean exclusive pinning.
CA pinning is the same process higher in the chain. The client remembers a CA certificate (which may be an "intermediate" CA) as a trust anchor. There again, this can be inclusive or exclusive. Exclusive CA pinning means that the browser will validate the server's certificate against that CA as unique trust anchor; the certificate will be accepted only if a chain can be built coming from that specific CA, and none other.
The important points above are the following:
- The client remembers a certificate from the server's certificate chain.
- The client complains loudly if the actual server's certificate (upon an ulterior connection) does not match what was remembered (subject possibly to some heuristics to smooth out normal renewals).
- This process is site-specific: this is the main departure of pinning from the usual "root CA store" model. What the client remembers and requires is for a specific target site. The remembered certificate (CA or not) is not general for all sites, but only for one.
-
Your comment was very descriptive and helpful. Thank you! Can you guide me as to where I could find references to read more on exclusive and inclusive certificate pinning ? Google doesn't quite return anything substantial. Commented Feb 12, 2014 at 19:42
Certificate pinning stores the fingerprint of the certificate for a site, so that (in addition to normal verification) if the certificate changes, this can be used as input to the validation process. The "pinned" certificate is not the CA, but the one at the end of the chain. You might display a warning to the user if, for instance, a certificate is replaced with another one 8 months before expiry.
It's way easier to get a fraudulent certificate or forge a signature on one than it is to generate one with the same modulus as an existing one. Certificate pinning is designed to provide some defense against the former.
-
Thank you for the prompt reply. Could you point out some helpful resources to understand in detail what transpires at the browser's end (in order to validate the authenticity of the site while pinning is in place) ? Commented Feb 12, 2014 at 1:34
-
There are lots of ways to do it, and lots of scopes (individual and network, etc.). OWASP gives a good overview: owasp.org/index.php/Certificate_and_Public_Key_Pinning Commented Feb 12, 2014 at 1:39