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

Side by Side Diff: net/base/cert_verify_proc_mac.cc

Issue 10855168: Rename X509Certificate::VerifyFlags to CertVerifier::VerifyFlags (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One missed mac define Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/cert_verify_proc.cc ('k') | net/base/cert_verify_proc_nss.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/cert_verify_proc_mac.h" 5 #include "net/base/cert_verify_proc_mac.h"
6 6
7 #include <CommonCrypto/CommonDigest.h> 7 #include <CommonCrypto/CommonDigest.h>
8 #include <CoreServices/CoreServices.h> 8 #include <CoreServices/CoreServices.h>
9 #include <Security/Security.h> 9 #include <Security/Security.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/mac/mac_logging.h" 12 #include "base/mac/mac_logging.h"
13 #include "base/mac/scoped_cftyperef.h" 13 #include "base/mac/scoped_cftyperef.h"
14 #include "base/sha1.h" 14 #include "base/sha1.h"
15 #include "base/string_piece.h" 15 #include "base/string_piece.h"
16 #include "crypto/nss_util.h" 16 #include "crypto/nss_util.h"
17 #include "crypto/sha2.h" 17 #include "crypto/sha2.h"
18 #include "net/base/asn1_util.h" 18 #include "net/base/asn1_util.h"
19 #include "net/base/cert_status_flags.h" 19 #include "net/base/cert_status_flags.h"
20 #include "net/base/cert_verifier.h"
20 #include "net/base/cert_verify_result.h" 21 #include "net/base/cert_verify_result.h"
21 #include "net/base/crl_set.h" 22 #include "net/base/crl_set.h"
22 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
23 #include "net/base/test_root_certs.h" 24 #include "net/base/test_root_certs.h"
24 #include "net/base/x509_certificate.h" 25 #include "net/base/x509_certificate.h"
25 #include "net/base/x509_certificate_known_roots_mac.h" 26 #include "net/base/x509_certificate_known_roots_mac.h"
26 #include "net/base/x509_util_mac.h" 27 #include "net/base/x509_util_mac.h"
27 28
28 // From 10.7.2 libsecurity_keychain-55035/lib/SecTrustPriv.h, for use with 29 // From 10.7.2 libsecurity_keychain-55035/lib/SecTrustPriv.h, for use with
29 // SecTrustCopyExtendedResult. 30 // SecTrustCopyExtendedResult.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 OSStatus status = x509_util::CreateSSLServerPolicy(hostname, &ssl_policy); 150 OSStatus status = x509_util::CreateSSLServerPolicy(hostname, &ssl_policy);
150 if (status) 151 if (status)
151 return status; 152 return status;
152 CFArrayAppendValue(local_policies, ssl_policy); 153 CFArrayAppendValue(local_policies, ssl_policy);
153 CFRelease(ssl_policy); 154 CFRelease(ssl_policy);
154 155
155 // Explicitly add revocation policies, in order to override system 156 // Explicitly add revocation policies, in order to override system
156 // revocation checking policies and instead respect the application-level 157 // revocation checking policies and instead respect the application-level
157 // revocation preference. 158 // revocation preference.
158 status = x509_util::CreateRevocationPolicies( 159 status = x509_util::CreateRevocationPolicies(
159 (flags & X509Certificate::VERIFY_REV_CHECKING_ENABLED), 160 (flags & CertVerifier::VERIFY_REV_CHECKING_ENABLED),
160 (flags & X509Certificate::VERIFY_REV_CHECKING_ENABLED_EV_ONLY), 161 (flags & CertVerifier::VERIFY_REV_CHECKING_ENABLED_EV_ONLY),
161 local_policies); 162 local_policies);
162 if (status) 163 if (status)
163 return status; 164 return status;
164 165
165 policies->reset(local_policies.release()); 166 policies->reset(local_policies.release());
166 return noErr; 167 return noErr;
167 } 168 }
168 169
169 // Saves some information about the certificate chain |cert_chain| in 170 // Saves some information about the certificate chain |cert_chain| in
170 // |*verify_result|. The caller MUST initialize |*verify_result| before 171 // |*verify_result|. The caller MUST initialize |*verify_result| before
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 CSSM_APPLE_TP_ACTION_DATA tp_action_data; 377 CSSM_APPLE_TP_ACTION_DATA tp_action_data;
377 memset(&tp_action_data, 0, sizeof(tp_action_data)); 378 memset(&tp_action_data, 0, sizeof(tp_action_data));
378 tp_action_data.Version = CSSM_APPLE_TP_ACTION_VERSION; 379 tp_action_data.Version = CSSM_APPLE_TP_ACTION_VERSION;
379 // Allow CSSM to download any missing intermediate certificates if an 380 // Allow CSSM to download any missing intermediate certificates if an
380 // authorityInfoAccess extension or issuerAltName extension is present. 381 // authorityInfoAccess extension or issuerAltName extension is present.
381 tp_action_data.ActionFlags = CSSM_TP_ACTION_FETCH_CERT_FROM_NET | 382 tp_action_data.ActionFlags = CSSM_TP_ACTION_FETCH_CERT_FROM_NET |
382 CSSM_TP_ACTION_TRUST_SETTINGS; 383 CSSM_TP_ACTION_TRUST_SETTINGS;
383 384
384 // Note: For EV certificates, the Apple TP will handle setting these flags 385 // Note: For EV certificates, the Apple TP will handle setting these flags
385 // as part of EV evaluation. 386 // as part of EV evaluation.
386 if (flags & X509Certificate::VERIFY_REV_CHECKING_ENABLED) { 387 if (flags & CertVerifier::VERIFY_REV_CHECKING_ENABLED) {
387 // Require a positive result from an OCSP responder or a CRL (or both) 388 // Require a positive result from an OCSP responder or a CRL (or both)
388 // for every certificate in the chain. The Apple TP automatically 389 // for every certificate in the chain. The Apple TP automatically
389 // excludes the self-signed root from this requirement. If a certificate 390 // excludes the self-signed root from this requirement. If a certificate
390 // is missing both a crlDistributionPoints extension and an 391 // is missing both a crlDistributionPoints extension and an
391 // authorityInfoAccess extension with an OCSP responder URL, then we 392 // authorityInfoAccess extension with an OCSP responder URL, then we
392 // will get a kSecTrustResultRecoverableTrustFailure back from 393 // will get a kSecTrustResultRecoverableTrustFailure back from
393 // SecTrustEvaluate(), with a 394 // SecTrustEvaluate(), with a
394 // CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK error code. In that case, 395 // CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK error code. In that case,
395 // we'll set our own result to include 396 // we'll set our own result to include
396 // CERT_STATUS_NO_REVOCATION_MECHANISM. If one or both extensions are 397 // CERT_STATUS_NO_REVOCATION_MECHANISM. If one or both extensions are
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 verify_result->cert_status |= CERT_STATUS_COMMON_NAME_INVALID; 530 verify_result->cert_status |= CERT_STATUS_COMMON_NAME_INVALID;
530 531
531 // TODO(wtc): Suppress CERT_STATUS_NO_REVOCATION_MECHANISM for now to be 532 // TODO(wtc): Suppress CERT_STATUS_NO_REVOCATION_MECHANISM for now to be
532 // compatible with Windows, which in turn implements this behavior to be 533 // compatible with Windows, which in turn implements this behavior to be
533 // compatible with WinHTTP, which doesn't report this error (bug 3004). 534 // compatible with WinHTTP, which doesn't report this error (bug 3004).
534 verify_result->cert_status &= ~CERT_STATUS_NO_REVOCATION_MECHANISM; 535 verify_result->cert_status &= ~CERT_STATUS_NO_REVOCATION_MECHANISM;
535 536
536 if (IsCertStatusError(verify_result->cert_status)) 537 if (IsCertStatusError(verify_result->cert_status))
537 return MapCertStatusToNetError(verify_result->cert_status); 538 return MapCertStatusToNetError(verify_result->cert_status);
538 539
539 if (flags & X509Certificate::VERIFY_EV_CERT) { 540 if (flags & CertVerifier::VERIFY_EV_CERT) {
540 // Determine the certificate's EV status using SecTrustCopyExtendedResult(), 541 // Determine the certificate's EV status using SecTrustCopyExtendedResult(),
541 // which we need to look up because the function wasn't added until 542 // which we need to look up because the function wasn't added until
542 // Mac OS X 10.5.7. 543 // Mac OS X 10.5.7.
543 // Note: "ExtendedResult" means extended validation results. 544 // Note: "ExtendedResult" means extended validation results.
544 CFBundleRef bundle = 545 CFBundleRef bundle =
545 CFBundleGetBundleWithIdentifier(CFSTR("com.apple.security")); 546 CFBundleGetBundleWithIdentifier(CFSTR("com.apple.security"));
546 if (bundle) { 547 if (bundle) {
547 SecTrustCopyExtendedResultFuncPtr copy_extended_result = 548 SecTrustCopyExtendedResultFuncPtr copy_extended_result =
548 reinterpret_cast<SecTrustCopyExtendedResultFuncPtr>( 549 reinterpret_cast<SecTrustCopyExtendedResultFuncPtr>(
549 CFBundleGetFunctionPointerForName(bundle, 550 CFBundleGetFunctionPointerForName(bundle,
(...skipping 10 matching lines...) Expand all
560 // releases, SecTrustCopyExtendedResult would only return noErr and 561 // releases, SecTrustCopyExtendedResult would only return noErr and
561 // populate ev_dict for EV certificates, but would always include 562 // populate ev_dict for EV certificates, but would always include
562 // kSecEVOrganizationName in that case, so checking for this key is 563 // kSecEVOrganizationName in that case, so checking for this key is
563 // appropriate for all known versions of SecTrustCopyExtendedResult. 564 // appropriate for all known versions of SecTrustCopyExtendedResult.
564 // The actual organization name is unneeded here and can be accessed 565 // The actual organization name is unneeded here and can be accessed
565 // through other means. All that matters here is the OS' conception 566 // through other means. All that matters here is the OS' conception
566 // of whether or not the certificate is EV. 567 // of whether or not the certificate is EV.
567 if (CFDictionaryContainsKey(ev_dict, 568 if (CFDictionaryContainsKey(ev_dict,
568 kSecEVOrganizationName)) { 569 kSecEVOrganizationName)) {
569 verify_result->cert_status |= CERT_STATUS_IS_EV; 570 verify_result->cert_status |= CERT_STATUS_IS_EV;
570 if (flags & X509Certificate::VERIFY_REV_CHECKING_ENABLED_EV_ONLY) 571 if (flags & CertVerifier::VERIFY_REV_CHECKING_ENABLED_EV_ONLY)
571 verify_result->cert_status |= CERT_STATUS_REV_CHECKING_ENABLED; 572 verify_result->cert_status |= CERT_STATUS_REV_CHECKING_ENABLED;
572 } 573 }
573 } 574 }
574 } 575 }
575 } 576 }
576 } 577 }
577 578
578 AppendPublicKeyHashes(completed_chain, &verify_result->public_key_hashes); 579 AppendPublicKeyHashes(completed_chain, &verify_result->public_key_hashes);
579 verify_result->is_issued_by_known_root = IsIssuedByKnownRoot(completed_chain); 580 verify_result->is_issued_by_known_root = IsIssuedByKnownRoot(completed_chain);
580 581
581 return OK; 582 return OK;
582 } 583 }
583 584
584 } // namespace net 585 } // namespace net
OLDNEW
« no previous file with comments | « net/base/cert_verify_proc.cc ('k') | net/base/cert_verify_proc_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698