OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "chrome/browser/ssl/ssl_error_classification.h" | 7 #include "chrome/browser/ssl/ssl_error_classification.h" |
8 | 8 |
9 #include "base/build_time.h" | 9 #include "base/build_time.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 } | 315 } |
316 | 316 |
317 SSLErrorClassification::Tokens SSLErrorClassification:: | 317 SSLErrorClassification::Tokens SSLErrorClassification:: |
318 Tokenize(const std::string& name) { | 318 Tokenize(const std::string& name) { |
319 Tokens name_tokens; | 319 Tokens name_tokens; |
320 base::SplitStringDontTrim(name, '.', &name_tokens); | 320 base::SplitStringDontTrim(name, '.', &name_tokens); |
321 return name_tokens; | 321 return name_tokens; |
322 } | 322 } |
323 | 323 |
324 // We accept the inverse case for www for historical reasons. | 324 // We accept the inverse case for www for historical reasons. |
325 bool SSLErrorClassification::IsWWWSubDomainMatch() const { | 325 bool SSLErrorClassification::GetWWWSubDomainMatch( |
326 std::string host_name = request_url_.host(); | 326 const std::string& host_name, |
327 const std::vector<std::string>& dns_names, | |
328 std::string* www_match_host_name) { | |
327 if (IsHostNameKnownTLD(host_name)) { | 329 if (IsHostNameKnownTLD(host_name)) { |
328 std::vector<std::string> dns_names; | |
329 cert_.GetDNSNames(&dns_names); | |
330 bool result = false; | 330 bool result = false; |
331 // Need to account for all possible domains given in the SSL certificate. | 331 // Need to account for all possible domains given in the SSL certificate. |
332 for (size_t i = 0; i < dns_names.size(); ++i) { | 332 for (size_t i = 0; i < dns_names.size(); ++i) { |
333 if (dns_names[i].empty() || dns_names[i].find('\0') != std::string::npos | 333 if (dns_names[i].empty() || dns_names[i].find('\0') != std::string::npos |
334 || dns_names[i].length() == host_name.length() | 334 || dns_names[i].length() == host_name.length() |
335 || !(IsHostNameKnownTLD(dns_names[i]))) { | 335 || !(IsHostNameKnownTLD(dns_names[i]))) { |
336 result = result || false; | 336 result = result || false; |
337 } else if (dns_names[i].length() > host_name.length()) { | 337 } else if (dns_names[i].length() > host_name.length()) { |
338 result = result || | 338 if (net::StripWWW(base::ASCIIToUTF16(dns_names[i])) == |
339 net::StripWWW(base::ASCIIToUTF16(dns_names[i])) == | 339 base::ASCIIToUTF16(host_name)) { |
340 base::ASCIIToUTF16(host_name); | 340 result = result || true; |
meacer
2015/07/09 17:58:56
result = result || true means result = true :)
Bhanu Dev
2015/07/11 04:00:43
Done.
| |
341 www_match_host_name->assign(dns_names[i].data(), dns_names[i].size()); | |
342 } | |
341 } else { | 343 } else { |
342 result = result || | 344 if (net::StripWWW(base::ASCIIToUTF16(host_name)) == |
343 net::StripWWW(base::ASCIIToUTF16(host_name)) == | 345 base::ASCIIToUTF16(dns_names[i])) { |
344 base::ASCIIToUTF16(dns_names[i]); | 346 result = result || true; |
meacer
2015/07/09 17:58:56
Same here.
Bhanu Dev
2015/07/11 04:00:43
Done.
| |
347 www_match_host_name->assign(dns_names[i].data(), dns_names[i].size()); | |
348 } | |
345 } | 349 } |
346 } | 350 } |
347 return result; | 351 return result; |
348 } | 352 } |
349 return false; | 353 return false; |
350 } | 354 } |
351 | 355 |
356 bool SSLErrorClassification::IsWWWSubDomainMatch() const { | |
357 std::string host_name = request_url_.host(); | |
358 std::vector<std::string> dns_names; | |
359 cert_.GetDNSNames(&dns_names); | |
360 std::string www_host; | |
361 return GetWWWSubDomainMatch(host_name, dns_names, &www_host); | |
362 } | |
363 | |
352 bool SSLErrorClassification::NameUnderAnyNames( | 364 bool SSLErrorClassification::NameUnderAnyNames( |
353 const Tokens& child, | 365 const Tokens& child, |
354 const std::vector<Tokens>& potential_parents) const { | 366 const std::vector<Tokens>& potential_parents) const { |
355 bool result = false; | 367 bool result = false; |
356 // Need to account for all the possible domains given in the SSL certificate. | 368 // Need to account for all the possible domains given in the SSL certificate. |
357 for (size_t i = 0; i < potential_parents.size(); ++i) { | 369 for (size_t i = 0; i < potential_parents.size(); ++i) { |
358 if (potential_parents[i].empty() || | 370 if (potential_parents[i].empty() || |
359 potential_parents[i].size() >= child.size()) { | 371 potential_parents[i].size() >= child.size()) { |
360 result = result || false; | 372 result = result || false; |
361 } else { | 373 } else { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 // sure we don't clear the captive protal flag, since the interstitial was | 505 // sure we don't clear the captive protal flag, since the interstitial was |
494 // potentially caused by the captive portal. | 506 // potentially caused by the captive portal. |
495 captive_portal_detected_ = captive_portal_detected_ || | 507 captive_portal_detected_ = captive_portal_detected_ || |
496 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 508 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
497 // Also keep track of non-HTTP portals and error cases. | 509 // Also keep track of non-HTTP portals and error cases. |
498 captive_portal_no_response_ = captive_portal_no_response_ || | 510 captive_portal_no_response_ = captive_portal_no_response_ || |
499 (results->result == captive_portal::RESULT_NO_RESPONSE); | 511 (results->result == captive_portal::RESULT_NO_RESPONSE); |
500 } | 512 } |
501 #endif | 513 #endif |
502 } | 514 } |
OLD | NEW |