[email protected] | e54d0af | 2012-03-03 01:07:15 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | c81d9dcc | 2010-03-17 00:51:44 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef NET_BASE_CERT_TEST_UTIL_H_ | ||||
6 | #define NET_BASE_CERT_TEST_UTIL_H_ | ||||
[email protected] | c81d9dcc | 2010-03-17 00:51:44 | [diff] [blame] | 7 | |
[email protected] | 32765f8 | 2010-12-16 00:01:37 | [diff] [blame] | 8 | #include <string> |
9 | |||||
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
[email protected] | 7d015e4 | 2012-03-14 16:15:12 | [diff] [blame] | 11 | #include "net/base/x509_cert_types.h" |
[email protected] | e54d0af | 2012-03-03 01:07:15 | [diff] [blame] | 12 | #include "net/base/x509_certificate.h" |
[email protected] | c81d9dcc | 2010-03-17 00:51:44 | [diff] [blame] | 13 | |
[email protected] | 864b136 | 2010-08-19 03:49:38 | [diff] [blame] | 14 | class FilePath; |
15 | |||||
[email protected] | c81d9dcc | 2010-03-17 00:51:44 | [diff] [blame] | 16 | namespace net { |
17 | |||||
[email protected] | 7d015e4 | 2012-03-14 16:15:12 | [diff] [blame] | 18 | class EVRootCAMetadata; |
19 | |||||
[email protected] | 32765f8 | 2010-12-16 00:01:37 | [diff] [blame] | 20 | // Returns a FilePath object representing the src/net/data/ssl/certificates |
21 | // directory in the source tree. | ||||
22 | FilePath GetTestCertsDirectory(); | ||||
23 | |||||
[email protected] | e54d0af | 2012-03-03 01:07:15 | [diff] [blame] | 24 | CertificateList CreateCertificateListFromFile(const FilePath& certs_dir, |
25 | const std::string& cert_file, | ||||
26 | int format); | ||||
27 | |||||
[email protected] | 32765f8 | 2010-12-16 00:01:37 | [diff] [blame] | 28 | // Imports a certificate file in the src/net/data/ssl/certificates directory. |
29 | // certs_dir represents the test certificates directory. cert_file is the | ||||
30 | // name of the certificate file. If cert_file contains multiple certificates, | ||||
31 | // the first certificate found will be returned. | ||||
32 | scoped_refptr<X509Certificate> ImportCertFromFile(const FilePath& certs_dir, | ||||
33 | const std::string& cert_file); | ||||
[email protected] | c81d9dcc | 2010-03-17 00:51:44 | [diff] [blame] | 34 | |
[email protected] | 7d015e4 | 2012-03-14 16:15:12 | [diff] [blame] | 35 | // ScopedTestEVPolicy causes certificates marked with |policy|, issued from a |
36 | // root with the given fingerprint, to be treated as EV. |policy| is expressed | ||||
37 | // as a string of dotted numbers: i.e. "1.2.3.4". | ||||
38 | // This should only be used in unittests as adding a CA twice causes a CHECK | ||||
39 | // failure. | ||||
40 | class ScopedTestEVPolicy { | ||||
41 | public: | ||||
42 | ScopedTestEVPolicy(EVRootCAMetadata* ev_root_ca_metadata, | ||||
[email protected] | ede0321 | 2012-09-07 12:52:26 | [diff] [blame^] | 43 | const SHA1HashValue& fingerprint, |
[email protected] | 7d015e4 | 2012-03-14 16:15:12 | [diff] [blame] | 44 | const char* policy); |
45 | ~ScopedTestEVPolicy(); | ||||
46 | |||||
47 | private: | ||||
[email protected] | ede0321 | 2012-09-07 12:52:26 | [diff] [blame^] | 48 | SHA1HashValue fingerprint_; |
[email protected] | 7d015e4 | 2012-03-14 16:15:12 | [diff] [blame] | 49 | EVRootCAMetadata* const ev_root_ca_metadata_; |
50 | }; | ||||
51 | |||||
[email protected] | c81d9dcc | 2010-03-17 00:51:44 | [diff] [blame] | 52 | } // namespace net |
53 | |||||
54 | #endif // NET_BASE_CERT_TEST_UTIL_H_ |