// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ssl/ssl_error_info.h" #include "base/i18n/time_formatting.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" #include "content/public/browser/cert_store.h" #include "net/base/escape.h" #include "net/base/net_errors.h" #include "net/cert/cert_status_flags.h" #include "net/ssl/ssl_info.h" #include "ui/base/l10n/l10n_util.h" #include "url/gurl.h" using base::UTF8ToUTF16; SSLErrorInfo::SSLErrorInfo(const base::string16& details, const base::string16& short_description) : details_(details), short_description_(short_description) { } // static SSLErrorInfo SSLErrorInfo::CreateError(ErrorType error_type, net::X509Certificate* cert, const GURL& request_url) { base::string16 details, short_description; switch (error_type) { case CERT_COMMON_NAME_INVALID: { // If the certificate contains multiple DNS names, we choose the most // representative one -- either the DNS name that's also in the subject // field, or the first one. If this heuristic turns out to be // inadequate, we can consider choosing the DNS name that is the // "closest match" to the host name in the request URL, or listing all // the DNS names with an HTML