blob: eb9e7eb292d85d5277e72b974b4f86c10065b50a [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]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]7d015e42012-03-14 16:15:1211#include "net/base/x509_cert_types.h"
[email protected]e54d0af2012-03-03 01:07:1512#include "net/base/x509_certificate.h"
[email protected]c81d9dcc2010-03-17 00:51:4413
[email protected]864b1362010-08-19 03:49:3814class FilePath;
15
[email protected]c81d9dcc2010-03-17 00:51:4416namespace net {
17
[email protected]7d015e42012-03-14 16:15:1218class EVRootCAMetadata;
19
[email protected]32765f82010-12-16 00:01:3720// Returns a FilePath object representing the src/net/data/ssl/certificates
21// directory in the source tree.
22FilePath GetTestCertsDirectory();
23
[email protected]e54d0af2012-03-03 01:07:1524CertificateList CreateCertificateListFromFile(const FilePath& certs_dir,
25 const std::string& cert_file,
26 int format);
27
[email protected]32765f82010-12-16 00:01:3728// 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.
32scoped_refptr<X509Certificate> ImportCertFromFile(const FilePath& certs_dir,
33 const std::string& cert_file);
[email protected]c81d9dcc2010-03-17 00:51:4434
[email protected]7d015e42012-03-14 16:15:1235// 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
39// failure.
40class ScopedTestEVPolicy {
41 public:
42 ScopedTestEVPolicy(EVRootCAMetadata* ev_root_ca_metadata,
[email protected]ede03212012-09-07 12:52:2643 const SHA1HashValue& fingerprint,
[email protected]7d015e42012-03-14 16:15:1244 const char* policy);
45 ~ScopedTestEVPolicy();
46
47 private:
[email protected]ede03212012-09-07 12:52:2648 SHA1HashValue fingerprint_;
[email protected]7d015e42012-03-14 16:15:1249 EVRootCAMetadata* const ev_root_ca_metadata_;
50};
51
[email protected]c81d9dcc2010-03-17 00:51:4452} // namespace net
53
54#endif // NET_BASE_CERT_TEST_UTIL_H_