blob: 31b768ae583b27f19bfa27b7760647e113d29a37 [file] [log] [blame]
[email protected]e54d0af2012-03-03 01:07:151// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]c81d9dcc2010-03-17 00:51:442// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]6e7845ae2013-03-29 21:48:115#ifndef NET_TEST_CERT_TEST_UTIL_H_
6#define NET_TEST_CERT_TEST_UTIL_H_
[email protected]c81d9dcc2010-03-17 00:51:447
[email protected]32765f82010-12-16 00:01:378#include <string>
9
[email protected]3b63f8f42011-03-28 01:54:1510#include "base/memory/ref_counted.h"
[email protected]6e7845ae2013-03-29 21:48:1111#include "net/cert/x509_cert_types.h"
12#include "net/cert/x509_certificate.h"
[email protected]c81d9dcc2010-03-17 00:51:4413
[email protected]a3ef4832013-02-02 05:12:3314namespace base {
[email protected]864b1362010-08-19 03:49:3815class FilePath;
[email protected]a3ef4832013-02-02 05:12:3316}
[email protected]864b1362010-08-19 03:49:3817
[email protected]c81d9dcc2010-03-17 00:51:4418namespace net {
19
[email protected]7d015e42012-03-14 16:15:1220class EVRootCAMetadata;
21
[email protected]1f11d6f2013-11-24 22:33:0022// Imports all of the certificates in |cert_file|, a file in |certs_dir|,
23// // into a CertificateList.
[email protected]a3ef4832013-02-02 05:12:3324CertificateList CreateCertificateListFromFile(const base::FilePath& certs_dir,
[email protected]e54d0af2012-03-03 01:07:1525 const std::string& cert_file,
26 int format);
27
[email protected]1f11d6f2013-11-24 22:33:0028// Imports all of the certificates in |cert_file|, a file in |certs_dir|, into
29// a new X509Certificate. The first certificate in the chain will be used for
30// the returned cert, with any additional certificates configured as
31// intermediate certificates.
32scoped_refptr<X509Certificate> CreateCertificateChainFromFile(
33 const base::FilePath& certs_dir,
34 const std::string& cert_file,
35 int format);
36
37// Imports a single certificate from |cert_file|.
[email protected]42fdb452012-11-01 12:44:4038// |certs_dir| represents the test certificates directory. |cert_file| is the
[email protected]32765f82010-12-16 00:01:3739// name of the certificate file. If cert_file contains multiple certificates,
40// the first certificate found will be returned.
[email protected]a3ef4832013-02-02 05:12:3341scoped_refptr<X509Certificate> ImportCertFromFile(const base::FilePath& certs_dir,
[email protected]32765f82010-12-16 00:01:3742 const std::string& cert_file);
[email protected]c81d9dcc2010-03-17 00:51:4443
[email protected]7d015e42012-03-14 16:15:1244// ScopedTestEVPolicy causes certificates marked with |policy|, issued from a
45// root with the given fingerprint, to be treated as EV. |policy| is expressed
46// as a string of dotted numbers: i.e. "1.2.3.4".
47// This should only be used in unittests as adding a CA twice causes a CHECK
48// failure.
49class ScopedTestEVPolicy {
50 public:
51 ScopedTestEVPolicy(EVRootCAMetadata* ev_root_ca_metadata,
[email protected]ede03212012-09-07 12:52:2652 const SHA1HashValue& fingerprint,
[email protected]7d015e42012-03-14 16:15:1253 const char* policy);
54 ~ScopedTestEVPolicy();
55
56 private:
[email protected]ede03212012-09-07 12:52:2657 SHA1HashValue fingerprint_;
[email protected]7d015e42012-03-14 16:15:1258 EVRootCAMetadata* const ev_root_ca_metadata_;
59};
60
[email protected]c81d9dcc2010-03-17 00:51:4461} // namespace net
62
[email protected]6e7845ae2013-03-29 21:48:1163#endif // NET_TEST_CERT_TEST_UTIL_H_