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 #include "net/cert/mock_cert_verifier.h" | 5 #include "net/cert/mock_cert_verifier.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 MockCertVerifier::MockCertVerifier() : default_result_(ERR_CERT_INVALID) {} | 39 MockCertVerifier::MockCertVerifier() : default_result_(ERR_CERT_INVALID) {} |
40 | 40 |
41 MockCertVerifier::~MockCertVerifier() {} | 41 MockCertVerifier::~MockCertVerifier() {} |
42 | 42 |
43 int MockCertVerifier::Verify(const RequestParams& params, | 43 int MockCertVerifier::Verify(const RequestParams& params, |
44 CRLSet* crl_set, | 44 CRLSet* crl_set, |
45 CertVerifyResult* verify_result, | 45 CertVerifyResult* verify_result, |
46 const CompletionCallback& callback, | 46 const CompletionCallback& callback, |
47 std::unique_ptr<Request>* out_req, | 47 std::unique_ptr<Request>* out_req, |
48 const BoundNetLog& net_log) { | 48 const NetLogWithSource& net_log) { |
49 RuleList::const_iterator it; | 49 RuleList::const_iterator it; |
50 for (it = rules_.begin(); it != rules_.end(); ++it) { | 50 for (it = rules_.begin(); it != rules_.end(); ++it) { |
51 // Check just the server cert. Intermediates will be ignored. | 51 // Check just the server cert. Intermediates will be ignored. |
52 if (!it->cert->Equals(params.certificate().get())) | 52 if (!it->cert->Equals(params.certificate().get())) |
53 continue; | 53 continue; |
54 if (!base::MatchPattern(params.hostname(), it->hostname)) | 54 if (!base::MatchPattern(params.hostname(), it->hostname)) |
55 continue; | 55 continue; |
56 *verify_result = it->result; | 56 *verify_result = it->result; |
57 return it->rv; | 57 return it->rv; |
58 } | 58 } |
(...skipping 12 matching lines...) Expand all Loading... |
71 | 71 |
72 void MockCertVerifier::AddResultForCertAndHost( | 72 void MockCertVerifier::AddResultForCertAndHost( |
73 scoped_refptr<X509Certificate> cert, | 73 scoped_refptr<X509Certificate> cert, |
74 const std::string& host_pattern, | 74 const std::string& host_pattern, |
75 const CertVerifyResult& verify_result, | 75 const CertVerifyResult& verify_result, |
76 int rv) { | 76 int rv) { |
77 rules_.push_back(Rule(std::move(cert), host_pattern, verify_result, rv)); | 77 rules_.push_back(Rule(std::move(cert), host_pattern, verify_result, rv)); |
78 } | 78 } |
79 | 79 |
80 } // namespace net | 80 } // namespace net |
OLD | NEW |