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

Side by Side Diff: net/base/x509_certificate.h

Issue 9584041: Create stubs for system certificate validation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Exclude CertVerifyProcNSS for non-NSS-only systems, for now Created 8 years, 9 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
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 #ifndef NET_BASE_X509_CERTIFICATE_H_ 5 #ifndef NET_BASE_X509_CERTIFICATE_H_
6 #define NET_BASE_X509_CERTIFICATE_H_ 6 #define NET_BASE_X509_CERTIFICATE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 // using GetChainDEREncodedBytes below. 362 // using GetChainDEREncodedBytes below.
363 void GetChainDEREncodedBytes(std::vector<std::string>* chain_bytes) const; 363 void GetChainDEREncodedBytes(std::vector<std::string>* chain_bytes) const;
364 #endif 364 #endif
365 365
366 #if defined(USE_OPENSSL) 366 #if defined(USE_OPENSSL)
367 // Returns a handle to a global, in-memory certificate store. We 367 // Returns a handle to a global, in-memory certificate store. We
368 // use it for test code, e.g. importing the test server's certificate. 368 // use it for test code, e.g. importing the test server's certificate.
369 static X509_STORE* cert_store(); 369 static X509_STORE* cert_store();
370 #endif 370 #endif
371 371
372 // Verifies the certificate against the given hostname. Returns OK if
373 // successful or an error code upon failure.
374 //
375 // The |*verify_result| structure, including the |verify_result->cert_status|
376 // bitmask, is always filled out regardless of the return value. If the
377 // certificate has multiple errors, the corresponding status flags are set in
378 // |verify_result->cert_status|, and the error code for the most serious
379 // error is returned.
380 //
381 // |flags| is bitwise OR'd of VerifyFlags:
382 //
383 // If VERIFY_REV_CHECKING_ENABLED is set in |flags|, online certificate
384 // revocation checking is performed (i.e. OCSP and downloading CRLs). CRLSet
385 // based revocation checking is always enabled, regardless of this flag, if
386 // |crl_set| is given.
387 //
388 // If VERIFY_EV_CERT is set in |flags| too, EV certificate verification is
389 // performed.
390 //
391 // |crl_set| points to an optional CRLSet structure which can be used to
392 // avoid revocation checks over the network.
393 int Verify(const std::string& hostname,
394 int flags,
395 CRLSet* crl_set,
396 CertVerifyResult* verify_result) const;
397
398 // Verifies that |hostname| matches this certificate. 372 // Verifies that |hostname| matches this certificate.
399 // Does not verify that the certificate is valid, only that the certificate 373 // Does not verify that the certificate is valid, only that the certificate
400 // matches this host. 374 // matches this host.
401 // Returns true if it matches. 375 // Returns true if it matches.
402 bool VerifyNameMatch(const std::string& hostname) const; 376 bool VerifyNameMatch(const std::string& hostname) const;
403 377
404 // Obtains the DER encoded certificate data for |cert_handle|. On success, 378 // Obtains the DER encoded certificate data for |cert_handle|. On success,
405 // returns true and writes the DER encoded certificate to |*der_encoded|. 379 // returns true and writes the DER encoded certificate to |*der_encoded|.
406 static bool GetDEREncoded(OSCertHandle cert_handle, 380 static bool GetDEREncoded(OSCertHandle cert_handle,
407 std::string* der_encoded); 381 std::string* der_encoded);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 static SHA1Fingerprint CalculateFingerprint(OSCertHandle cert_handle); 442 static SHA1Fingerprint CalculateFingerprint(OSCertHandle cert_handle);
469 443
470 // Calculates the SHA-1 fingerprint of the intermediate CA certificates. 444 // Calculates the SHA-1 fingerprint of the intermediate CA certificates.
471 // Returns an empty (all zero) fingerprint on failure. 445 // Returns an empty (all zero) fingerprint on failure.
472 static SHA1Fingerprint CalculateCAFingerprint( 446 static SHA1Fingerprint CalculateCAFingerprint(
473 const OSCertHandles& intermediates); 447 const OSCertHandles& intermediates);
474 448
475 private: 449 private:
476 friend class base::RefCountedThreadSafe<X509Certificate>; 450 friend class base::RefCountedThreadSafe<X509Certificate>;
477 friend class TestRootCerts; // For unit tests 451 friend class TestRootCerts; // For unit tests
478 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, Cache); 452 // TODO(rsleevi): Temporary refactoring - http://crbug.com/114343
479 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, IntermediateCertificates); 453 friend class X509CertificateTest;
454 friend class CertVerifyProcMac;
455 friend class CertVerifyProcNSS;
456 friend class CertVerifyProcOpenSSL;
457 friend class CertVerifyProcWin;
458
459 FRIEND_TEST_ALL_PREFIXES(X509CertificateNameVerifyTest, VerifyHostname);
460 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, DigiNotarCerts);
480 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, SerialNumbers); 461 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, SerialNumbers);
481 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, DigiNotarCerts);
482 FRIEND_TEST_ALL_PREFIXES(X509CertificateNameVerifyTest, VerifyHostname);
483 462
484 // Construct an X509Certificate from a handle to the certificate object 463 // Construct an X509Certificate from a handle to the certificate object
485 // in the underlying crypto library. 464 // in the underlying crypto library.
486 X509Certificate(OSCertHandle cert_handle, 465 X509Certificate(OSCertHandle cert_handle,
487 const OSCertHandles& intermediates); 466 const OSCertHandles& intermediates);
488 467
489 ~X509Certificate(); 468 ~X509Certificate();
490 469
491 // Common object initialization code. Called by the constructors only. 470 // Common object initialization code. Called by the constructors only.
492 void Initialize(); 471 void Initialize();
493 472
473
474 // Verifies the certificate against the given hostname. Returns OK if
475 // successful or an error code upon failure.
476 //
477 // The |*verify_result| structure, including the |verify_result->cert_status|
478 // bitmask, is always filled out regardless of the return value. If the
479 // certificate has multiple errors, the corresponding status flags are set in
480 // |verify_result->cert_status|, and the error code for the most serious
481 // error is returned.
482 //
483 // |flags| is bitwise OR'd of VerifyFlags:
484 //
485 // If VERIFY_REV_CHECKING_ENABLED is set in |flags|, online certificate
486 // revocation checking is performed (i.e. OCSP and downloading CRLs). CRLSet
487 // based revocation checking is always enabled, regardless of this flag, if
488 // |crl_set| is given.
489 //
490 // If VERIFY_EV_CERT is set in |flags| too, EV certificate verification is
491 // performed.
492 //
493 // |crl_set| points to an optional CRLSet structure which can be used to
494 // avoid revocation checks over the network.
495 int Verify(const std::string& hostname,
496 int flags,
497 CRLSet* crl_set,
498 CertVerifyResult* verify_result) const;
499
494 #if defined(OS_WIN) 500 #if defined(OS_WIN)
495 bool CheckEV(PCCERT_CHAIN_CONTEXT chain_context, 501 bool CheckEV(PCCERT_CHAIN_CONTEXT chain_context,
496 const char* policy_oid) const; 502 const char* policy_oid) const;
497 static bool IsIssuedByKnownRoot(PCCERT_CHAIN_CONTEXT chain_context); 503 static bool IsIssuedByKnownRoot(PCCERT_CHAIN_CONTEXT chain_context);
498 #endif 504 #endif
499 #if defined(OS_MACOSX) 505 #if defined(OS_MACOSX)
500 static bool IsIssuedByKnownRoot(CFArrayRef chain); 506 static bool IsIssuedByKnownRoot(CFArrayRef chain);
501 #endif 507 #endif
502 #if defined(USE_NSS) 508 #if defined(USE_NSS)
503 bool VerifyEV(int flags) const; 509 bool VerifyEV(int flags) const;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 // (Marked mutable because it's used in a const method.) 606 // (Marked mutable because it's used in a const method.)
601 mutable base::Lock verification_lock_; 607 mutable base::Lock verification_lock_;
602 #endif 608 #endif
603 609
604 DISALLOW_COPY_AND_ASSIGN(X509Certificate); 610 DISALLOW_COPY_AND_ASSIGN(X509Certificate);
605 }; 611 };
606 612
607 } // namespace net 613 } // namespace net
608 614
609 #endif // NET_BASE_X509_CERTIFICATE_H_ 615 #endif // NET_BASE_X509_CERTIFICATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698