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
3 // found in the LICENSE file.
5 #ifndef NET_BASE_CERT_TEST_UTIL_H_
6 #define NET_BASE_CERT_TEST_UTIL_H_
10 #include "base/memory/ref_counted.h"
11 #include "net/base/x509_cert_types.h"
12 #include "net/base/x509_certificate.h"
18 class EVRootCAMetadata
;
20 // Returns a FilePath object representing the src/net/data/ssl/certificates
21 // directory in the source tree.
22 FilePath
GetTestCertsDirectory();
24 CertificateList
CreateCertificateListFromFile(const FilePath
& certs_dir
,
25 const std::string
& cert_file
,
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
);
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
40 class ScopedTestEVPolicy
{
42 ScopedTestEVPolicy(EVRootCAMetadata
* ev_root_ca_metadata
,
43 const SHA1Fingerprint
& fingerprint
,
45 ~ScopedTestEVPolicy();
48 SHA1Fingerprint fingerprint_
;
49 EVRootCAMetadata
* const ev_root_ca_metadata_
;
54 #endif // NET_BASE_CERT_TEST_UTIL_H_