blob: 15ceb5859f970a9ccf7e7075230691acf8f6b20c [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
5#ifndef NET_BASE_CERT_TEST_UTIL_H_
6#define NET_BASE_CERT_TEST_UTIL_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]c81d9dcc2010-03-17 00:51:448
[email protected]32765f82010-12-16 00:01:379#include <string>
10
[email protected]3b63f8f42011-03-28 01:54:1511#include "base/memory/ref_counted.h"
[email protected]7d015e42012-03-14 16:15:1212#include "net/base/x509_cert_types.h"
[email protected]e54d0af2012-03-03 01:07:1513#include "net/base/x509_certificate.h"
[email protected]c81d9dcc2010-03-17 00:51:4414
[email protected]864b1362010-08-19 03:49:3815class FilePath;
16
[email protected]c81d9dcc2010-03-17 00:51:4417namespace net {
18
[email protected]7d015e42012-03-14 16:15:1219class EVRootCAMetadata;
20
[email protected]32765f82010-12-16 00:01:3721// Returns a FilePath object representing the src/net/data/ssl/certificates
22// directory in the source tree.
23FilePath GetTestCertsDirectory();
24
[email protected]e54d0af2012-03-03 01:07:1525CertificateList CreateCertificateListFromFile(const FilePath& certs_dir,
26 const std::string& cert_file,
27 int format);
28
[email protected]32765f82010-12-16 00:01:3729// 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.
33scoped_refptr<X509Certificate> ImportCertFromFile(const FilePath& certs_dir,
34 const std::string& cert_file);
[email protected]c81d9dcc2010-03-17 00:51:4435
[email protected]7d015e42012-03-14 16:15:1236// 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.
41class 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]c81d9dcc2010-03-17 00:51:4453} // namespace net
54
55#endif // NET_BASE_CERT_TEST_UTIL_H_