OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/cert/cert_verify_proc_nss.h" | 5 #include "net/cert/cert_verify_proc_nss.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include <cert.h> | 10 #include <cert.h> |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return MapNetErrorToCertStatus(net_error); | 151 return MapNetErrorToCertStatus(net_error); |
152 } | 152 } |
153 | 153 |
154 // Saves some information about the certificate chain cert_list in | 154 // Saves some information about the certificate chain cert_list in |
155 // *verify_result. The caller MUST initialize *verify_result before calling | 155 // *verify_result. The caller MUST initialize *verify_result before calling |
156 // this function. | 156 // this function. |
157 // Note that cert_list[0] is the end entity certificate. | 157 // Note that cert_list[0] is the end entity certificate. |
158 void GetCertChainInfo(CERTCertList* cert_list, | 158 void GetCertChainInfo(CERTCertList* cert_list, |
159 CERTCertificate* root_cert, | 159 CERTCertificate* root_cert, |
160 CertVerifyResult* verify_result) { | 160 CertVerifyResult* verify_result) { |
| 161 // NOTE: Using a NSS library before 3.12.3.1 will crash below. To see the |
| 162 // NSS version currently in use: |
| 163 // 1. use ldd on the chrome executable for NSS's location (ie. libnss3.so*) |
| 164 // 2. use ident libnss3.so* for the library's version |
161 DCHECK(cert_list); | 165 DCHECK(cert_list); |
162 | 166 |
163 CERTCertificate* verified_cert = NULL; | 167 CERTCertificate* verified_cert = NULL; |
164 std::vector<CERTCertificate*> verified_chain; | 168 std::vector<CERTCertificate*> verified_chain; |
165 int i = 0; | 169 int i = 0; |
166 for (CERTCertListNode* node = CERT_LIST_HEAD(cert_list); | 170 for (CERTCertListNode* node = CERT_LIST_HEAD(cert_list); |
167 !CERT_LIST_END(node, cert_list); | 171 !CERT_LIST_END(node, cert_list); |
168 node = CERT_LIST_NEXT(node), ++i) { | 172 node = CERT_LIST_NEXT(node), ++i) { |
169 if (i == 0) { | 173 if (i == 0) { |
170 verified_cert = node->cert; | 174 verified_cert = node->cert; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 SECStatus PKIXVerifyCert(CERTCertificate* cert_handle, | 339 SECStatus PKIXVerifyCert(CERTCertificate* cert_handle, |
336 bool check_revocation, | 340 bool check_revocation, |
337 bool cert_io_enabled, | 341 bool cert_io_enabled, |
338 const SECOidTag* policy_oids, | 342 const SECOidTag* policy_oids, |
339 int num_policy_oids, | 343 int num_policy_oids, |
340 CERTCertList* additional_trust_anchors, | 344 CERTCertList* additional_trust_anchors, |
341 CERTValOutParam* cvout) { | 345 CERTValOutParam* cvout) { |
342 bool use_crl = check_revocation; | 346 bool use_crl = check_revocation; |
343 bool use_ocsp = check_revocation; | 347 bool use_ocsp = check_revocation; |
344 | 348 |
| 349 // These CAs have multiple keys, which trigger two bugs in NSS's CRL code. |
| 350 // 1. NSS may use one key to verify a CRL signed with another key, |
| 351 // incorrectly concluding that the CRL's signature is invalid. |
| 352 // Hopefully this bug will be fixed in NSS 3.12.9. |
| 353 // 2. NSS considers all certificates issued by the CA as revoked when it |
| 354 // receives a CRL with an invalid signature. This overly strict policy |
| 355 // has been relaxed in NSS 3.12.7. See |
| 356 // https://bugzilla.mozilla.org/show_bug.cgi?id=562542. |
| 357 // So we have to turn off CRL checking for these CAs. See |
| 358 // http://crbug.com/55695. |
| 359 static const char* const kMultipleKeyCA[] = { |
| 360 "CN=Microsoft Secure Server Authority," |
| 361 "DC=redmond,DC=corp,DC=microsoft,DC=com", |
| 362 "CN=Microsoft Secure Server Authority", |
| 363 }; |
| 364 |
| 365 if (!NSS_VersionCheck("3.12.7")) { |
| 366 for (size_t i = 0; i < arraysize(kMultipleKeyCA); ++i) { |
| 367 if (strcmp(cert_handle->issuerName, kMultipleKeyCA[i]) == 0) { |
| 368 use_crl = false; |
| 369 break; |
| 370 } |
| 371 } |
| 372 } |
| 373 |
345 PRUint64 revocation_method_flags = | 374 PRUint64 revocation_method_flags = |
346 CERT_REV_M_DO_NOT_TEST_USING_THIS_METHOD | | 375 CERT_REV_M_DO_NOT_TEST_USING_THIS_METHOD | |
347 CERT_REV_M_ALLOW_NETWORK_FETCHING | | 376 CERT_REV_M_ALLOW_NETWORK_FETCHING | |
348 CERT_REV_M_IGNORE_IMPLICIT_DEFAULT_SOURCE | | 377 CERT_REV_M_IGNORE_IMPLICIT_DEFAULT_SOURCE | |
349 CERT_REV_M_IGNORE_MISSING_FRESH_INFO | | 378 CERT_REV_M_IGNORE_MISSING_FRESH_INFO | |
350 CERT_REV_M_STOP_TESTING_ON_FRESH_INFO; | 379 CERT_REV_M_STOP_TESTING_ON_FRESH_INFO; |
351 PRUint64 revocation_method_independent_flags = | 380 PRUint64 revocation_method_independent_flags = |
352 CERT_REV_MI_TEST_ALL_LOCAL_INFORMATION_FIRST; | 381 CERT_REV_MI_TEST_ALL_LOCAL_INFORMATION_FIRST; |
353 if (check_revocation && policy_oids && num_policy_oids > 0) { | 382 if (check_revocation && policy_oids && num_policy_oids > 0) { |
354 // EV verification requires revocation checking. Consider the certificate | 383 // EV verification requires revocation checking. Consider the certificate |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 if ((flags & CertVerifier::VERIFY_EV_CERT) && is_ev_candidate && | 868 if ((flags & CertVerifier::VERIFY_EV_CERT) && is_ev_candidate && |
840 VerifyEV(cert_handle, flags, crl_set, metadata, ev_policy_oid, | 869 VerifyEV(cert_handle, flags, crl_set, metadata, ev_policy_oid, |
841 trust_anchors.get())) { | 870 trust_anchors.get())) { |
842 verify_result->cert_status |= CERT_STATUS_IS_EV; | 871 verify_result->cert_status |= CERT_STATUS_IS_EV; |
843 } | 872 } |
844 | 873 |
845 return OK; | 874 return OK; |
846 } | 875 } |
847 | 876 |
848 } // namespace net | 877 } // namespace net |
OLD | NEW |