blob: db49e87327c8ea431e582ff803398f5933a825e1 [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]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]a3ef4832013-02-02 05:12:3322CertificateList CreateCertificateListFromFile(const base::FilePath& certs_dir,
[email protected]e54d0af2012-03-03 01:07:1523 const std::string& cert_file,
24 int format);
25
[email protected]42fdb452012-11-01 12:44:4026// 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]32765f82010-12-16 00:01:3729// name of the certificate file. If cert_file contains multiple certificates,
30// the first certificate found will be returned.
[email protected]a3ef4832013-02-02 05:12:3331scoped_refptr<X509Certificate> ImportCertFromFile(const base::FilePath& certs_dir,
[email protected]32765f82010-12-16 00:01:3732 const std::string& cert_file);
[email protected]c81d9dcc2010-03-17 00:51:4433
[email protected]7d015e42012-03-14 16:15:1234// 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.
39class ScopedTestEVPolicy {
40 public:
41 ScopedTestEVPolicy(EVRootCAMetadata* ev_root_ca_metadata,
[email protected]ede03212012-09-07 12:52:2642 const SHA1HashValue& fingerprint,
[email protected]7d015e42012-03-14 16:15:1243 const char* policy);
44 ~ScopedTestEVPolicy();
45
46 private:
[email protected]ede03212012-09-07 12:52:2647 SHA1HashValue fingerprint_;
[email protected]7d015e42012-03-14 16:15:1248 EVRootCAMetadata* const ev_root_ca_metadata_;
49};
50
[email protected]c81d9dcc2010-03-17 00:51:4451} // namespace net
52
53#endif // NET_BASE_CERT_TEST_UTIL_H_