Chromium Code Reviews| 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 #ifndef NET_TEST_CERT_TEST_UTIL_H_ | 5 #ifndef NET_TEST_CERT_TEST_UTIL_H_ |
| 6 #define NET_TEST_CERT_TEST_UTIL_H_ | 6 #define NET_TEST_CERT_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "net/cert/x509_cert_types.h" | 11 #include "net/cert/x509_cert_types.h" |
| 12 #include "net/cert/x509_certificate.h" | 12 #include "net/cert/x509_certificate.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class FilePath; | 15 class FilePath; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 | 19 |
| 20 class EVRootCAMetadata; | 20 class EVRootCAMetadata; |
| 21 | 21 // Imports all of the certificates in |cert_file|, a file in |certs_dir|, |
|
wtc
2013/11/21 02:05:02
Add a blank line before this comment.
Eran M. (Google)
2013/11/21 20:06:02
Done.
| |
| 22 // // into a CertificateList. | |
| 22 CertificateList CreateCertificateListFromFile(const base::FilePath& certs_dir, | 23 CertificateList CreateCertificateListFromFile(const base::FilePath& certs_dir, |
| 23 const std::string& cert_file, | 24 const std::string& cert_file, |
| 24 int format); | 25 int format); |
| 25 | 26 |
| 26 // Imports a certificate file in the directory net::GetTestCertsDirectory() | 27 // Imports all of the certificates in |cert_file|, a file in |certs_dir|, into |
| 27 // returns. | 28 // a new X509Certificate. The first certificate in the chain will be used for |
| 29 // the returned cert, with any additional certificates configured as | |
| 30 // intermediate certificates. | |
| 31 scoped_refptr<X509Certificate> CreateCertificateChainFromFile( | |
| 32 const base::FilePath& certs_dir, | |
| 33 const std::string& cert_file, | |
| 34 int format); | |
| 35 | |
| 36 // Imports a single certificate from |cert_file|. | |
|
wtc
2013/11/21 02:05:02
Nit: it seems useful to keep the original comment
Eran M. (Google)
2013/11/21 20:06:02
Done.
| |
| 28 // |certs_dir| represents the test certificates directory. |cert_file| is the | 37 // |certs_dir| represents the test certificates directory. |cert_file| is the |
| 29 // name of the certificate file. If cert_file contains multiple certificates, | 38 // name of the certificate file. |
| 30 // the first certificate found will be returned. | |
| 31 scoped_refptr<X509Certificate> ImportCertFromFile(const base::FilePath& certs_di r, | 39 scoped_refptr<X509Certificate> ImportCertFromFile(const base::FilePath& certs_di r, |
| 32 const std::string& cert_file); | 40 const std::string& cert_file); |
| 33 | 41 |
| 34 // ScopedTestEVPolicy causes certificates marked with |policy|, issued from a | 42 // ScopedTestEVPolicy causes certificates marked with |policy|, issued from a |
| 35 // root with the given fingerprint, to be treated as EV. |policy| is expressed | 43 // root with the given fingerprint, to be treated as EV. |policy| is expressed |
| 36 // as a string of dotted numbers: i.e. "1.2.3.4". | 44 // as a string of dotted numbers: i.e. "1.2.3.4". |
| 37 // This should only be used in unittests as adding a CA twice causes a CHECK | 45 // This should only be used in unittests as adding a CA twice causes a CHECK |
| 38 // failure. | 46 // failure. |
| 39 class ScopedTestEVPolicy { | 47 class ScopedTestEVPolicy { |
| 40 public: | 48 public: |
| 41 ScopedTestEVPolicy(EVRootCAMetadata* ev_root_ca_metadata, | 49 ScopedTestEVPolicy(EVRootCAMetadata* ev_root_ca_metadata, |
| 42 const SHA1HashValue& fingerprint, | 50 const SHA1HashValue& fingerprint, |
| 43 const char* policy); | 51 const char* policy); |
| 44 ~ScopedTestEVPolicy(); | 52 ~ScopedTestEVPolicy(); |
| 45 | 53 |
| 46 private: | 54 private: |
| 47 SHA1HashValue fingerprint_; | 55 SHA1HashValue fingerprint_; |
| 48 EVRootCAMetadata* const ev_root_ca_metadata_; | 56 EVRootCAMetadata* const ev_root_ca_metadata_; |
| 49 }; | 57 }; |
| 50 | 58 |
| 51 } // namespace net | 59 } // namespace net |
| 52 | 60 |
| 53 #endif // NET_TEST_CERT_TEST_UTIL_H_ | 61 #endif // NET_TEST_CERT_TEST_UTIL_H_ |
| OLD | NEW |