| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_TEST_CERT_TEST_UTIL_H_ | 5 #ifndef NET_TEST_CERT_TEST_UTIL_H_ |
| 6 #define NET_TEST_CERT_TEST_UTIL_H_ | 6 #define NET_TEST_CERT_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // intermediate certificates. | 31 // intermediate certificates. |
| 32 scoped_refptr<X509Certificate> CreateCertificateChainFromFile( | 32 scoped_refptr<X509Certificate> CreateCertificateChainFromFile( |
| 33 const base::FilePath& certs_dir, | 33 const base::FilePath& certs_dir, |
| 34 const std::string& cert_file, | 34 const std::string& cert_file, |
| 35 int format); | 35 int format); |
| 36 | 36 |
| 37 // Imports a single certificate from |cert_file|. | 37 // Imports a single certificate from |cert_file|. |
| 38 // |certs_dir| represents the test certificates directory. |cert_file| is the | 38 // |certs_dir| represents the test certificates directory. |cert_file| is the |
| 39 // name of the certificate file. If cert_file contains multiple certificates, | 39 // name of the certificate file. If cert_file contains multiple certificates, |
| 40 // the first certificate found will be returned. | 40 // the first certificate found will be returned. |
| 41 scoped_refptr<X509Certificate> ImportCertFromFile(const base::FilePath& certs_di
r, | 41 scoped_refptr<X509Certificate> ImportCertFromFile( |
| 42 const std::string& cert_file); | 42 const base::FilePath& certs_dir, |
| 43 const std::string& cert_file); |
| 43 | 44 |
| 44 // ScopedTestEVPolicy causes certificates marked with |policy|, issued from a | 45 // ScopedTestEVPolicy causes certificates marked with |policy|, issued from a |
| 45 // root with the given fingerprint, to be treated as EV. |policy| is expressed | 46 // 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 // 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 // This should only be used in unittests as adding a CA twice causes a CHECK |
| 48 // failure. | 49 // failure. |
| 49 class ScopedTestEVPolicy { | 50 class ScopedTestEVPolicy { |
| 50 public: | 51 public: |
| 51 ScopedTestEVPolicy(EVRootCAMetadata* ev_root_ca_metadata, | 52 ScopedTestEVPolicy(EVRootCAMetadata* ev_root_ca_metadata, |
| 52 const SHA1HashValue& fingerprint, | 53 const SHA1HashValue& fingerprint, |
| 53 const char* policy); | 54 const char* policy); |
| 54 ~ScopedTestEVPolicy(); | 55 ~ScopedTestEVPolicy(); |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 SHA1HashValue fingerprint_; | 58 SHA1HashValue fingerprint_; |
| 58 EVRootCAMetadata* const ev_root_ca_metadata_; | 59 EVRootCAMetadata* const ev_root_ca_metadata_; |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 } // namespace net | 62 } // namespace net |
| 62 | 63 |
| 63 #endif // NET_TEST_CERT_TEST_UTIL_H_ | 64 #endif // NET_TEST_CERT_TEST_UTIL_H_ |
| OLD | NEW |