Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Unified Diff: net/base/x509_certificate_nss.cc

Issue 9271060: Check cert->isRoot to skip extraneous root certificates in certificate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Improve comments and add a unit test Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/x509_certificate_unittest.cc » ('j') | net/base/x509_certificate_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/x509_certificate_nss.cc
===================================================================
--- net/base/x509_certificate_nss.cc (revision 119153)
+++ net/base/x509_certificate_nss.cc (working copy)
@@ -192,8 +192,36 @@
if (i == 0) {
verified_cert = node->cert;
} else {
+ // Because of an NSS bug, CERT_PKIXVerifyCert may chain a self-signed
+ // certificate of a root CA to another certificate of the same root CA
+ // key. Detect that error and ignore the root CA certificate.
+ // See https://bugzilla.mozilla.org/show_bug.cgi?id=721288.
+ //
+ // NOTE: isRoot doesn't mean the certificate is a trust anchor. It
+ // means the certificate is self-signed.
Ryan Sleevi 2012/01/27 21:45:37 nit: self-issued? This is to match comments in li
wtc 2012/01/27 22:58:13 isRoot means self-signed as defined in PKIX (RFC 5
+ if (node->cert->isRoot) {
+ CERTCertListNode* next_node = CERT_LIST_NEXT(node);
+ CERTCertificate* next_cert;
+ if (!CERT_LIST_END(next_node, cert_list)) {
+ next_cert = next_node->cert;
+ } else {
+ next_cert = root_cert;
+ }
+ // Test that |node->cert| is actually a self-signed certificate
+ // whose key is equal to |next_cert|, and not a self-issued
+ // certificate signed by another key of the same CA.
+ //
+ // This SECITEM_ItemsAreEqual test should be unnecessary, implied
+ // by node->cert->isRoot and the fact that NSS has verified the
+ // signature of node->cert with the public key of next_cert.
+ if (next_cert && SECITEM_ItemsAreEqual(&node->cert->derPublicKey,
Ryan Sleevi 2012/01/27 21:45:37 This isn't for checking the signature of node->cer
+ &next_cert->derPublicKey)) {
+ continue;
+ }
+ }
verified_chain.push_back(node->cert);
}
+
SECAlgorithmID& signature = node->cert->signature;
SECOidTag oid_tag = SECOID_FindOIDTag(&signature.algorithm);
switch (oid_tag) {
« no previous file with comments | « no previous file | net/base/x509_certificate_unittest.cc » ('j') | net/base/x509_certificate_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698