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 "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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 | 26 |
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 // First we check if we know the policy for this error. | 36 // First we check if we know the policy for this error. |
36 net::CertPolicy::Judgment judgment = | 37 net::CertPolicy::Judgment judgment = |
37 backend_->QueryPolicy(handler->ssl_info().cert.get(), | 38 backend_->QueryPolicy(handler->ssl_info().cert.get(), |
38 handler->request_url().host(), | 39 handler->request_url().host(), |
39 handler->cert_error()); | 40 handler->cert_error(), |
| 41 &expired_previous_decision); |
40 | 42 |
41 if (judgment == net::CertPolicy::ALLOWED) { | 43 if (judgment == net::CertPolicy::ALLOWED) { |
42 handler->ContinueRequest(); | 44 handler->ContinueRequest(); |
43 return; | 45 return; |
44 } | 46 } |
45 | 47 |
46 // The judgment is either DENIED or UNKNOWN. | 48 // The judgment is either DENIED or UNKNOWN. |
47 // For now we handle the DENIED as the UNKNOWN, which means a blocking | 49 // For now we handle the DENIED as the UNKNOWN, which means a blocking |
48 // page is shown to the user every time he comes back to the page. | 50 // page is shown to the user every time he comes back to the page. |
49 | 51 |
50 switch (handler->cert_error()) { | 52 switch (handler->cert_error()) { |
51 case net::ERR_CERT_COMMON_NAME_INVALID: | 53 case net::ERR_CERT_COMMON_NAME_INVALID: |
52 case net::ERR_CERT_DATE_INVALID: | 54 case net::ERR_CERT_DATE_INVALID: |
53 case net::ERR_CERT_AUTHORITY_INVALID: | 55 case net::ERR_CERT_AUTHORITY_INVALID: |
54 case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM: | 56 case net::ERR_CERT_WEAK_SIGNATURE_ALGORITHM: |
55 case net::ERR_CERT_WEAK_KEY: | 57 case net::ERR_CERT_WEAK_KEY: |
56 case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION: | 58 case net::ERR_CERT_NAME_CONSTRAINT_VIOLATION: |
57 OnCertErrorInternal(handler, !handler->fatal(), handler->fatal()); | 59 OnCertErrorInternal(handler, |
| 60 !handler->fatal(), |
| 61 handler->fatal(), |
| 62 expired_previous_decision); |
58 break; | 63 break; |
59 case net::ERR_CERT_NO_REVOCATION_MECHANISM: | 64 case net::ERR_CERT_NO_REVOCATION_MECHANISM: |
60 // Ignore this error. | 65 // Ignore this error. |
61 handler->ContinueRequest(); | 66 handler->ContinueRequest(); |
62 break; | 67 break; |
63 case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION: | 68 case net::ERR_CERT_UNABLE_TO_CHECK_REVOCATION: |
64 // We ignore this error but will show a warning status in the location | 69 // We ignore this error but will show a warning status in the location |
65 // bar. | 70 // bar. |
66 handler->ContinueRequest(); | 71 handler->ContinueRequest(); |
67 break; | 72 break; |
68 case net::ERR_CERT_CONTAINS_ERRORS: | 73 case net::ERR_CERT_CONTAINS_ERRORS: |
69 case net::ERR_CERT_REVOKED: | 74 case net::ERR_CERT_REVOKED: |
70 case net::ERR_CERT_INVALID: | 75 case net::ERR_CERT_INVALID: |
71 case net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY: | 76 case net::ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY: |
72 case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN: | 77 case net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN: |
73 OnCertErrorInternal(handler, false, handler->fatal()); | 78 OnCertErrorInternal( |
| 79 handler, false, handler->fatal(), expired_previous_decision); |
74 break; | 80 break; |
75 default: | 81 default: |
76 NOTREACHED(); | 82 NOTREACHED(); |
77 handler->CancelRequest(); | 83 handler->CancelRequest(); |
78 break; | 84 break; |
79 } | 85 } |
80 } | 86 } |
81 | 87 |
82 void SSLPolicy::DidRunInsecureContent(NavigationEntryImpl* entry, | 88 void SSLPolicy::DidRunInsecureContent(NavigationEntryImpl* entry, |
83 const std::string& security_origin) { | 89 const std::string& security_origin) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 handler->cert_error()); | 182 handler->cert_error()); |
177 handler->CancelRequest(); | 183 handler->CancelRequest(); |
178 } | 184 } |
179 } | 185 } |
180 | 186 |
181 //////////////////////////////////////////////////////////////////////////////// | 187 //////////////////////////////////////////////////////////////////////////////// |
182 // Certificate Error Routines | 188 // Certificate Error Routines |
183 | 189 |
184 void SSLPolicy::OnCertErrorInternal(SSLCertErrorHandler* handler, | 190 void SSLPolicy::OnCertErrorInternal(SSLCertErrorHandler* handler, |
185 bool overridable, | 191 bool overridable, |
186 bool strict_enforcement) { | 192 bool strict_enforcement, |
| 193 bool expired_previous_decision) { |
187 CertificateRequestResultType result = | 194 CertificateRequestResultType result = |
188 CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE; | 195 CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE; |
189 GetContentClient()->browser()->AllowCertificateError( | 196 GetContentClient()->browser()->AllowCertificateError( |
190 handler->render_process_id(), | 197 handler->render_process_id(), |
191 handler->render_frame_id(), | 198 handler->render_frame_id(), |
192 handler->cert_error(), | 199 handler->cert_error(), |
193 handler->ssl_info(), | 200 handler->ssl_info(), |
194 handler->request_url(), | 201 handler->request_url(), |
195 handler->resource_type(), | 202 handler->resource_type(), |
196 overridable, | 203 overridable, |
197 strict_enforcement, | 204 strict_enforcement, |
198 base::Bind(&SSLPolicy::OnAllowCertificate, base::Unretained(this), | 205 expired_previous_decision, |
| 206 base::Bind(&SSLPolicy::OnAllowCertificate, |
| 207 base::Unretained(this), |
199 make_scoped_refptr(handler)), | 208 make_scoped_refptr(handler)), |
200 &result); | 209 &result); |
201 switch (result) { | 210 switch (result) { |
202 case CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE: | 211 case CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE: |
203 break; | 212 break; |
204 case CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL: | 213 case CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL: |
205 handler->CancelRequest(); | 214 handler->CancelRequest(); |
206 break; | 215 break; |
207 case CERTIFICATE_REQUEST_RESULT_TYPE_DENY: | 216 case CERTIFICATE_REQUEST_RESULT_TYPE_DENY: |
208 handler->DenyRequest(); | 217 handler->DenyRequest(); |
(...skipping 11 matching lines...) Expand all Loading... |
220 SECURITY_STYLE_AUTHENTICATED : SECURITY_STYLE_UNAUTHENTICATED; | 229 SECURITY_STYLE_AUTHENTICATED : SECURITY_STYLE_UNAUTHENTICATED; |
221 } | 230 } |
222 | 231 |
223 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) { | 232 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) { |
224 GURL parsed_origin(origin); | 233 GURL parsed_origin(origin); |
225 if (parsed_origin.SchemeIsSecure()) | 234 if (parsed_origin.SchemeIsSecure()) |
226 backend_->HostRanInsecureContent(parsed_origin.host(), pid); | 235 backend_->HostRanInsecureContent(parsed_origin.host(), pid); |
227 } | 236 } |
228 | 237 |
229 } // namespace content | 238 } // namespace content |
OLD | NEW |