[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 | |||||
[email protected] | 6e7845ae | 2013-03-29 21:48:11 | [diff] [blame^] | 5 | #ifndef NET_TEST_CERT_TEST_UTIL_H_ |
6 | #define NET_TEST_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] | 6e7845ae | 2013-03-29 21:48:11 | [diff] [blame^] | 11 | #include "net/cert/x509_cert_types.h" |
12 | #include "net/cert/x509_certificate.h" | ||||
[email protected] | c81d9dcc | 2010-03-17 00:51:44 | [diff] [blame] | 13 | |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 14 | namespace base { |
[email protected] | 864b136 | 2010-08-19 03:49:38 | [diff] [blame] | 15 | class FilePath; |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 16 | } |
[email protected] | 864b136 | 2010-08-19 03:49:38 | [diff] [blame] | 17 | |
[email protected] | c81d9dcc | 2010-03-17 00:51:44 | [diff] [blame] | 18 | namespace net { |
19 | |||||
[email protected] | 7d015e4 | 2012-03-14 16:15:12 | [diff] [blame] | 20 | class EVRootCAMetadata; |
21 | |||||
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 22 | CertificateList CreateCertificateListFromFile(const base::FilePath& certs_dir, |
[email protected] | e54d0af | 2012-03-03 01:07:15 | [diff] [blame] | 23 | const std::string& cert_file, |
24 | int format); | ||||
25 | |||||
[email protected] | 42fdb45 | 2012-11-01 12:44:40 | [diff] [blame] | 26 | // Imports a certificate file in the directory net::GetTestCertsDirectory() |
27 | // returns. | ||||
28 | // |certs_dir| represents the test certificates directory. |cert_file| is the | ||||
[email protected] | 32765f8 | 2010-12-16 00:01:37 | [diff] [blame] | 29 | // name of the certificate file. If cert_file contains multiple certificates, |
30 | // the first certificate found will be returned. | ||||
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 31 | scoped_refptr<X509Certificate> ImportCertFromFile(const base::FilePath& certs_dir, |
[email protected] | 32765f8 | 2010-12-16 00:01:37 | [diff] [blame] | 32 | const std::string& cert_file); |
[email protected] | c81d9dcc | 2010-03-17 00:51:44 | [diff] [blame] | 33 | |
[email protected] | 7d015e4 | 2012-03-14 16:15:12 | [diff] [blame] | 34 | // ScopedTestEVPolicy causes certificates marked with |policy|, issued from a |
35 | // 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". | ||||
37 | // This should only be used in unittests as adding a CA twice causes a CHECK | ||||
38 | // failure. | ||||
39 | class ScopedTestEVPolicy { | ||||
40 | public: | ||||
41 | ScopedTestEVPolicy(EVRootCAMetadata* ev_root_ca_metadata, | ||||
[email protected] | ede0321 | 2012-09-07 12:52:26 | [diff] [blame] | 42 | const SHA1HashValue& fingerprint, |
[email protected] | 7d015e4 | 2012-03-14 16:15:12 | [diff] [blame] | 43 | const char* policy); |
44 | ~ScopedTestEVPolicy(); | ||||
45 | |||||
46 | private: | ||||
[email protected] | ede0321 | 2012-09-07 12:52:26 | [diff] [blame] | 47 | SHA1HashValue fingerprint_; |
[email protected] | 7d015e4 | 2012-03-14 16:15:12 | [diff] [blame] | 48 | EVRootCAMetadata* const ev_root_ca_metadata_; |
49 | }; | ||||
50 | |||||
[email protected] | c81d9dcc | 2010-03-17 00:51:44 | [diff] [blame] | 51 | } // namespace net |
52 | |||||
[email protected] | 6e7845ae | 2013-03-29 21:48:11 | [diff] [blame^] | 53 | #endif // NET_TEST_CERT_TEST_UTIL_H_ |