OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/web/net/cert_verifier_block_adapter.h" | 5 #include "ios/web/net/cert_verifier_block_adapter.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/mac/bind_objc_block.h" | 9 #include "base/mac/bind_objc_block.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 completion_handler(net::CertVerifyResult(), net::ERR_INVALID_ARGUMENT); | 80 completion_handler(net::CertVerifyResult(), net::ERR_INVALID_ARGUMENT); |
81 return; | 81 return; |
82 } | 82 } |
83 | 83 |
84 scoped_refptr<VerificationContext> context( | 84 scoped_refptr<VerificationContext> context( |
85 new VerificationContext(params.cert, net_log_)); | 85 new VerificationContext(params.cert, net_log_)); |
86 net::CompletionCallback callback = base::BindBlock(^(int error) { | 86 net::CompletionCallback callback = base::BindBlock(^(int error) { |
87 completion_handler(context->result, error); | 87 completion_handler(context->result, error); |
88 }); | 88 }); |
89 std::unique_ptr<net::CertVerifier::Request> request; | 89 std::unique_ptr<net::CertVerifier::Request> request; |
90 int error = cert_verifier_->Verify(params.cert.get(), params.hostname, | 90 int error = cert_verifier_->Verify( |
91 params.ocsp_response, params.flags, | 91 net::CertVerifier::RequestParams(params.cert.get(), params.hostname, |
92 params.crl_set.get(), &(context->result), | 92 params.flags, params.ocsp_response, |
93 callback, &request, context->net_log); | 93 net::CertificateList()), |
| 94 params.crl_set.get(), &(context->result), callback, &request, |
| 95 context->net_log); |
94 if (error == net::ERR_IO_PENDING) { | 96 if (error == net::ERR_IO_PENDING) { |
95 // Keep the |net::CertVerifier::Request| alive until verification completes. | 97 // Keep the |net::CertVerifier::Request| alive until verification completes. |
96 // Because |context| is kept alive by |callback| (through base::BindBlock), | 98 // Because |context| is kept alive by |callback| (through base::BindBlock), |
97 // this means that the cert verification request cannot be cancelled. | 99 // this means that the cert verification request cannot be cancelled. |
98 // However, it guarantees that |callback| - and thus |completion_handler| - | 100 // However, it guarantees that |callback| - and thus |completion_handler| - |
99 // will always be called, which is a necessary part of the API contract of | 101 // will always be called, which is a necessary part of the API contract of |
100 // |CertVerifierBlockAdapter::Verify()|. | 102 // |CertVerifierBlockAdapter::Verify()|. |
101 context->request = std::move(request); | 103 context->request = std::move(request); |
102 // Completion handler will be called from |callback| when verification | 104 // Completion handler will be called from |callback| when verification |
103 // request is completed. | 105 // request is completed. |
104 return; | 106 return; |
105 } | 107 } |
106 | 108 |
107 // Verification has either failed or result was retrieved from the cache. | 109 // Verification has either failed or result was retrieved from the cache. |
108 completion_handler(context->result, error); | 110 completion_handler(context->result, error); |
109 } | 111 } |
110 | 112 |
111 } // namespace web | 113 } // namespace web |
OLD | NEW |