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

Side by Side Diff: content/browser/ssl/ssl_policy.cc

Issue 465133004: Remove DenyCertForHost from SSLHostStateDelegate API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sleevi comments Created 6 years, 3 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 | Annotate | Revision Log
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 "content/browser/ssl/ssl_policy.h" 5 #include "content/browser/ssl/ssl_policy.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 16 matching lines...) Expand all
27 namespace content { 27 namespace content {
28 28
29 SSLPolicy::SSLPolicy(SSLPolicyBackend* backend) 29 SSLPolicy::SSLPolicy(SSLPolicyBackend* backend)
30 : backend_(backend) { 30 : backend_(backend) {
31 DCHECK(backend_); 31 DCHECK(backend_);
32 } 32 }
33 33
34 void SSLPolicy::OnCertError(SSLCertErrorHandler* handler) { 34 void SSLPolicy::OnCertError(SSLCertErrorHandler* handler) {
35 bool expired_previous_decision; 35 bool expired_previous_decision;
36 // First we check if we know the policy for this error. 36 // First we check if we know the policy for this error.
37 net::CertPolicy::Judgment judgment = 37 SSLHostStateDelegate::CertJudgment judgment =
38 backend_->QueryPolicy(handler->ssl_info().cert.get(), 38 backend_->QueryPolicy(handler->ssl_info().cert.get(),
39 handler->request_url().host(), 39 handler->request_url().host(),
40 handler->cert_error(), 40 handler->cert_error(),
41 &expired_previous_decision); 41 &expired_previous_decision);
42 42
43 if (judgment == net::CertPolicy::ALLOWED) { 43 if (judgment == SSLHostStateDelegate::ALLOWED) {
44 handler->ContinueRequest(); 44 handler->ContinueRequest();
45 return; 45 return;
46 } 46 }
47 47
48 // The judgment is either DENIED or UNKNOWN. 48 // For all other hosts, which must be DENIED, a blocking page is shown to the
49 // For now we handle the DENIED as the UNKNOWN, which means a blocking 49 // user every time they come back to the page.
50 // page is shown to the user every time he comes back to the page.
51
52 int options_mask = 0; 50 int options_mask = 0;
53 switch (handler->cert_error()) { 51 switch (handler->cert_error()) {
54 case net::ERR_CERT_COMMON_NAME_INVALID: 52 case net::ERR_CERT_COMMON_NAME_INVALID:
55 case net::ERR_CERT_DATE_INVALID: 53 case net::ERR_CERT_DATE_INVALID:
56 case net::ERR_CERT_AUTHORITY_INVALID: 54 case net::ERR_CERT_AUTHORITY_INVALID:
57 case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM: 55 case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM:
58 case net::ERR_CERT_WEAK_KEY: 56 case net::ERR_CERT_WEAK_KEY:
59 case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION: 57 case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION:
60 if (!handler->fatal()) 58 if (!handler->fatal())
61 options_mask |= OVERRIDABLE; 59 options_mask |= OVERRIDABLE;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // 171 //
174 // While AllowCertForHost() executes synchronously on this thread, 172 // While AllowCertForHost() executes synchronously on this thread,
175 // ContinueRequest() gets posted to a different thread. Calling 173 // ContinueRequest() gets posted to a different thread. Calling
176 // AllowCertForHost() first ensures deterministic ordering. 174 // AllowCertForHost() first ensures deterministic ordering.
177 backend_->AllowCertForHost(handler->ssl_info().cert.get(), 175 backend_->AllowCertForHost(handler->ssl_info().cert.get(),
178 handler->request_url().host(), 176 handler->request_url().host(),
179 handler->cert_error()); 177 handler->cert_error());
180 handler->ContinueRequest(); 178 handler->ContinueRequest();
181 } else { 179 } else {
182 // Default behavior for rejecting a certificate. 180 // Default behavior for rejecting a certificate.
183 //
184 // While DenyCertForHost() executes synchronously on this thread,
185 // CancelRequest() gets posted to a different thread. Calling
186 // DenyCertForHost() first ensures deterministic ordering.
187 backend_->DenyCertForHost(handler->ssl_info().cert.get(),
188 handler->request_url().host(),
189 handler->cert_error());
190 handler->CancelRequest(); 181 handler->CancelRequest();
191 } 182 }
192 } 183 }
193 184
194 //////////////////////////////////////////////////////////////////////////////// 185 ////////////////////////////////////////////////////////////////////////////////
195 // Certificate Error Routines 186 // Certificate Error Routines
196 187
197 void SSLPolicy::OnCertErrorInternal(SSLCertErrorHandler* handler, 188 void SSLPolicy::OnCertErrorInternal(SSLCertErrorHandler* handler,
198 int options_mask) { 189 int options_mask) {
199 bool overridable = (options_mask & OVERRIDABLE) != 0; 190 bool overridable = (options_mask & OVERRIDABLE) != 0;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 SECURITY_STYLE_AUTHENTICATED : SECURITY_STYLE_UNAUTHENTICATED; 229 SECURITY_STYLE_AUTHENTICATED : SECURITY_STYLE_UNAUTHENTICATED;
239 } 230 }
240 231
241 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) { 232 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) {
242 GURL parsed_origin(origin); 233 GURL parsed_origin(origin);
243 if (parsed_origin.SchemeIsSecure()) 234 if (parsed_origin.SchemeIsSecure())
244 backend_->HostRanInsecureContent(parsed_origin.host(), pid); 235 backend_->HostRanInsecureContent(parsed_origin.host(), pid);
245 } 236 }
246 237
247 } // namespace content 238 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698