// Copyright 2015 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 "components/ssl_errors/error_info.h" #include "base/i18n/message_formatter.h" #include "base/strings/utf_string_conversions.h" #include "grit/components_strings.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; namespace ssl_errors { ErrorInfo::ErrorInfo(const base::string16& details, const base::string16& short_description) : details_(details), short_description_(short_description) {} // static ErrorInfo ErrorInfo::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