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_BASE_CERT_TEST_UTIL_H_ | 5 #ifndef NET_BASE_CERT_TEST_UTIL_H_ |
6 #define NET_BASE_CERT_TEST_UTIL_H_ | 6 #define NET_BASE_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/base/x509_cert_types.h" | 11 #include "net/base/x509_cert_types.h" |
12 #include "net/base/x509_certificate.h" | 12 #include "net/base/x509_certificate.h" |
13 | 13 |
| 14 namespace base { |
14 class FilePath; | 15 class FilePath; |
| 16 } |
15 | 17 |
16 namespace net { | 18 namespace net { |
17 | 19 |
18 class EVRootCAMetadata; | 20 class EVRootCAMetadata; |
19 | 21 |
20 CertificateList CreateCertificateListFromFile(const FilePath& certs_dir, | 22 CertificateList CreateCertificateListFromFile(const base::FilePath& certs_dir, |
21 const std::string& cert_file, | 23 const std::string& cert_file, |
22 int format); | 24 int format); |
23 | 25 |
24 // Imports a certificate file in the directory net::GetTestCertsDirectory() | 26 // Imports a certificate file in the directory net::GetTestCertsDirectory() |
25 // returns. | 27 // returns. |
26 // |certs_dir| represents the test certificates directory. |cert_file| is the | 28 // |certs_dir| represents the test certificates directory. |cert_file| is the |
27 // name of the certificate file. If cert_file contains multiple certificates, | 29 // name of the certificate file. If cert_file contains multiple certificates, |
28 // the first certificate found will be returned. | 30 // the first certificate found will be returned. |
29 scoped_refptr<X509Certificate> ImportCertFromFile(const FilePath& certs_dir, | 31 scoped_refptr<X509Certificate> ImportCertFromFile(const base::FilePath& certs_di
r, |
30 const std::string& cert_file); | 32 const std::string& cert_file); |
31 | 33 |
32 // ScopedTestEVPolicy causes certificates marked with |policy|, issued from a | 34 // ScopedTestEVPolicy causes certificates marked with |policy|, issued from a |
33 // root with the given fingerprint, to be treated as EV. |policy| is expressed | 35 // root with the given fingerprint, to be treated as EV. |policy| is expressed |
34 // as a string of dotted numbers: i.e. "1.2.3.4". | 36 // as a string of dotted numbers: i.e. "1.2.3.4". |
35 // This should only be used in unittests as adding a CA twice causes a CHECK | 37 // This should only be used in unittests as adding a CA twice causes a CHECK |
36 // failure. | 38 // failure. |
37 class ScopedTestEVPolicy { | 39 class ScopedTestEVPolicy { |
38 public: | 40 public: |
39 ScopedTestEVPolicy(EVRootCAMetadata* ev_root_ca_metadata, | 41 ScopedTestEVPolicy(EVRootCAMetadata* ev_root_ca_metadata, |
40 const SHA1HashValue& fingerprint, | 42 const SHA1HashValue& fingerprint, |
41 const char* policy); | 43 const char* policy); |
42 ~ScopedTestEVPolicy(); | 44 ~ScopedTestEVPolicy(); |
43 | 45 |
44 private: | 46 private: |
45 SHA1HashValue fingerprint_; | 47 SHA1HashValue fingerprint_; |
46 EVRootCAMetadata* const ev_root_ca_metadata_; | 48 EVRootCAMetadata* const ev_root_ca_metadata_; |
47 }; | 49 }; |
48 | 50 |
49 } // namespace net | 51 } // namespace net |
50 | 52 |
51 #endif // NET_BASE_CERT_TEST_UTIL_H_ | 53 #endif // NET_BASE_CERT_TEST_UTIL_H_ |
OLD | NEW |