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