Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: net/cert/mock_cert_verifier.cc

Issue 1115903002: Refactor the API for CertVerifier::Verify() and the implementation of MultiThreadedCertVerifier::Ver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/cert/cert_status_flags.h" 10 #include "net/cert/cert_status_flags.h"
(...skipping 25 matching lines...) Expand all
36 36
37 MockCertVerifier::~MockCertVerifier() {} 37 MockCertVerifier::~MockCertVerifier() {}
38 38
39 int MockCertVerifier::Verify(X509Certificate* cert, 39 int MockCertVerifier::Verify(X509Certificate* cert,
40 const std::string& hostname, 40 const std::string& hostname,
41 const std::string& ocsp_response, 41 const std::string& ocsp_response,
42 int flags, 42 int flags,
43 CRLSet* crl_set, 43 CRLSet* crl_set,
44 CertVerifyResult* verify_result, 44 CertVerifyResult* verify_result,
45 const CompletionCallback& callback, 45 const CompletionCallback& callback,
46 RequestHandle* out_req, 46 scoped_ptr<Request>* out_req,
47 const BoundNetLog& net_log) { 47 const BoundNetLog& net_log) {
48 RuleList::const_iterator it; 48 RuleList::const_iterator it;
49 for (it = rules_.begin(); it != rules_.end(); ++it) { 49 for (it = rules_.begin(); it != rules_.end(); ++it) {
50 // Check just the server cert. Intermediates will be ignored. 50 // Check just the server cert. Intermediates will be ignored.
51 if (!it->cert->Equals(cert)) 51 if (!it->cert->Equals(cert))
52 continue; 52 continue;
53 if (!MatchPattern(hostname, it->hostname)) 53 if (!MatchPattern(hostname, it->hostname))
54 continue; 54 continue;
55 *verify_result = it->result; 55 *verify_result = it->result;
56 return it->rv; 56 return it->rv;
57 } 57 }
58 58
59 // Fall through to the default. 59 // Fall through to the default.
60 verify_result->verified_cert = cert; 60 verify_result->verified_cert = cert;
61 verify_result->cert_status = MapNetErrorToCertStatus(default_result_); 61 verify_result->cert_status = MapNetErrorToCertStatus(default_result_);
62 return default_result_; 62 return default_result_;
63 } 63 }
64 64
65 void MockCertVerifier::CancelRequest(RequestHandle req) {
66 NOTIMPLEMENTED();
67 }
68
69 void MockCertVerifier::AddResultForCert(X509Certificate* cert, 65 void MockCertVerifier::AddResultForCert(X509Certificate* cert,
70 const CertVerifyResult& verify_result, 66 const CertVerifyResult& verify_result,
71 int rv) { 67 int rv) {
72 AddResultForCertAndHost(cert, "*", verify_result, rv); 68 AddResultForCertAndHost(cert, "*", verify_result, rv);
73 } 69 }
74 70
75 void MockCertVerifier::AddResultForCertAndHost( 71 void MockCertVerifier::AddResultForCertAndHost(
76 X509Certificate* cert, 72 X509Certificate* cert,
77 const std::string& host_pattern, 73 const std::string& host_pattern,
78 const CertVerifyResult& verify_result, 74 const CertVerifyResult& verify_result,
79 int rv) { 75 int rv) {
80 Rule rule(cert, host_pattern, verify_result, rv); 76 Rule rule(cert, host_pattern, verify_result, rv);
81 rules_.push_back(rule); 77 rules_.push_back(rule);
82 } 78 }
83 79
84 } // namespace net 80 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698