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

Unified Diff: chrome/browser/ssl/ssl_error_classification.cc

Issue 1223233002: Common Name Mismatch Handler For WWW Subdomain Mismatch case (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolving comments Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ssl/ssl_error_classification.h ('k') | chrome/browser/ssl/ssl_error_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ssl/ssl_error_classification.cc
diff --git a/chrome/browser/ssl/ssl_error_classification.cc b/chrome/browser/ssl/ssl_error_classification.cc
index 305b2bbb0f0910614d9a105db71c8590194353d2..dc953fa3afa0ba2ea0949d5e73e941391a7af654 100644
--- a/chrome/browser/ssl/ssl_error_classification.cc
+++ b/chrome/browser/ssl/ssl_error_classification.cc
@@ -324,33 +324,44 @@ Tokenize(const std::string& name) {
}
// We accept the inverse case for www for historical reasons.
-bool SSLErrorClassification::IsWWWSubDomainMatch() const {
- std::string host_name = request_url_.host();
+bool SSLErrorClassification::GetWWWSubDomainMatch(
+ const std::string& host_name,
+ const std::vector<std::string>& dns_names,
+ std::string* www_match_host_name) {
if (IsHostNameKnownTLD(host_name)) {
- std::vector<std::string> dns_names;
- cert_.GetDNSNames(&dns_names);
- bool result = false;
// Need to account for all possible domains given in the SSL certificate.
for (size_t i = 0; i < dns_names.size(); ++i) {
- if (dns_names[i].empty() || dns_names[i].find('\0') != std::string::npos
- || dns_names[i].length() == host_name.length()
- || !(IsHostNameKnownTLD(dns_names[i]))) {
- result = result || false;
+ if (dns_names[i].empty() ||
+ dns_names[i].find('\0') != std::string::npos ||
+ dns_names[i].length() == host_name.length() ||
+ !IsHostNameKnownTLD(dns_names[i])) {
+ continue;
} else if (dns_names[i].length() > host_name.length()) {
- result = result ||
- net::StripWWW(base::ASCIIToUTF16(dns_names[i])) ==
- base::ASCIIToUTF16(host_name);
+ if (net::StripWWW(base::ASCIIToUTF16(dns_names[i])) ==
+ base::ASCIIToUTF16(host_name)) {
+ *www_match_host_name = dns_names[i];
+ return true;
+ }
} else {
- result = result ||
- net::StripWWW(base::ASCIIToUTF16(host_name)) ==
- base::ASCIIToUTF16(dns_names[i]);
+ if (net::StripWWW(base::ASCIIToUTF16(host_name)) ==
+ base::ASCIIToUTF16(dns_names[i])) {
+ *www_match_host_name = dns_names[i];
+ return true;
+ }
}
}
- return result;
}
return false;
}
+bool SSLErrorClassification::IsWWWSubDomainMatch() const {
+ const std::string& host_name = request_url_.host();
+ std::vector<std::string> dns_names;
+ cert_.GetDNSNames(&dns_names);
+ std::string www_host;
+ return GetWWWSubDomainMatch(host_name, dns_names, &www_host);
+}
+
bool SSLErrorClassification::NameUnderAnyNames(
const Tokens& child,
const std::vector<Tokens>& potential_parents) const {
« no previous file with comments | « chrome/browser/ssl/ssl_error_classification.h ('k') | chrome/browser/ssl/ssl_error_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698