| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "net/quic/test_tools/crypto_test_utils.h" | 5 #include "net/quic/test_tools/crypto_test_utils.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/base/test_data_directory.h" | 10 #include "net/base/test_data_directory.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 | 107 |
| 108 private: | 108 private: |
| 109 DISALLOW_COPY_AND_ASSIGN(FakeProofVerifier); | 109 DISALLOW_COPY_AND_ASSIGN(FakeProofVerifier); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace | 112 } // namespace |
| 113 | 113 |
| 114 // static | 114 // static |
| 115 ProofSource* CryptoTestUtils::ProofSourceForTesting() { | 115 ProofSource* CryptoTestUtils::ProofSourceForTesting() { |
| 116 // TODO(wtc): delete USE_OPENSSL when Chromium has a working |
| 117 // ProofSourceForTesting() for NSS. |
| 118 // TODO(rch): Implement a NSS proof source. |
| 119 #if defined(USE_OPENSSL) |
| 116 ProofSourceChromium* source = new ProofSourceChromium(); | 120 ProofSourceChromium* source = new ProofSourceChromium(); |
| 117 base::FilePath certs_dir = GetTestCertsDirectory(); | 121 base::FilePath certs_dir = GetTestCertsDirectory(); |
| 118 CHECK(source->Initialize( | 122 CHECK(source->Initialize( |
| 119 certs_dir.AppendASCII("quic_chain.crt"), | 123 certs_dir.AppendASCII("quic_chain.crt"), |
| 120 certs_dir.AppendASCII("quic_test.example.com.key.pkcs8"))); | 124 certs_dir.AppendASCII("quic_test.example.com.key.pkcs8"))); |
| 121 return source; | 125 return source; |
| 126 #else |
| 127 return FakeProofSourceForTesting(); |
| 128 #endif |
| 122 } | 129 } |
| 123 | 130 |
| 124 // static | 131 // static |
| 125 ProofVerifier* CryptoTestUtils::ProofVerifierForTesting() { | 132 ProofVerifier* CryptoTestUtils::ProofVerifierForTesting() { |
| 126 // TODO(rch): use a real cert verifier? | 133 // TODO(rch): use a real cert verifier? |
| 127 scoped_ptr<MockCertVerifier> cert_verifier(new MockCertVerifier()); | 134 scoped_ptr<MockCertVerifier> cert_verifier(new MockCertVerifier()); |
| 128 net::CertVerifyResult verify_result; | 135 net::CertVerifyResult verify_result; |
| 129 verify_result.verified_cert = | 136 verify_result.verified_cert = |
| 130 ImportCertFromFile(GetTestCertsDirectory(), "quic_test.example.com.crt"); | 137 ImportCertFromFile(GetTestCertsDirectory(), "quic_test.example.com.crt"); |
| 131 cert_verifier->AddResultForCertAndHost(verify_result.verified_cert.get(), | 138 cert_verifier->AddResultForCertAndHost(verify_result.verified_cert.get(), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 155 } | 162 } |
| 156 | 163 |
| 157 // static | 164 // static |
| 158 ProofVerifyContext* CryptoTestUtils::FakeProofVerifyContextForTesting() { | 165 ProofVerifyContext* CryptoTestUtils::FakeProofVerifyContextForTesting() { |
| 159 return nullptr; | 166 return nullptr; |
| 160 } | 167 } |
| 161 | 168 |
| 162 } // namespace test | 169 } // namespace test |
| 163 | 170 |
| 164 } // namespace net | 171 } // namespace net |
| OLD | NEW |