1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SSL_ERRORS_SSL_ERROR_INFO_H_
6 #define COMPONENTS_SSL_ERRORS_SSL_ERROR_INFO_H_
11 #include "base/strings/string16.h"
12 #include "net/cert/cert_status_flags.h"
13 #include "net/cert/x509_certificate.h"
17 namespace ssl_errors
{
19 // This class describes an error that happened while showing a page over SSL.
20 // An ErrorInfo object only exists on the UI thread and only contains
21 // information about an error (type of error and text details).
22 // Note no DISALLOW_COPY_AND_ASSIGN as we want the copy constructor.
25 // This enum is being histogrammed; please only add new values at the end.
27 CERT_COMMON_NAME_INVALID
= 0,
29 CERT_AUTHORITY_INVALID
,
31 CERT_NO_REVOCATION_MECHANISM
,
32 CERT_UNABLE_TO_CHECK_REVOCATION
,
35 CERT_WEAK_SIGNATURE_ALGORITHM
,
37 CERT_NAME_CONSTRAINT_VIOLATION
,
40 CERT_PINNED_KEY_MISSING
,
41 CERT_VALIDITY_TOO_LONG
,
47 // Converts a network error code to an ErrorType.
48 static ErrorType
NetErrorToErrorType(int net_error
);
50 static ErrorInfo
CreateError(ErrorType error_type
,
51 net::X509Certificate
* cert
,
52 const GURL
& request_url
);
54 // Populates the specified |errors| vector with the errors contained in
55 // |cert_status| for |cert|. Returns the number of errors found.
56 // Callers only interested in the error count can pass NULL for |errors|.
57 static void GetErrorsForCertStatus(
58 const scoped_refptr
<net::X509Certificate
>& cert
,
59 net::CertStatus cert_status
,
61 std::vector
<ErrorInfo
>* errors
);
63 // A description of the error.
64 const base::string16
& details() const { return details_
; }
66 // A short message describing the error (1 line).
67 const base::string16
& short_description() const { return short_description_
; }
70 ErrorInfo(const base::string16
& details
,
71 const base::string16
& short_description
);
73 base::string16 details_
;
74 base::string16 short_description_
;
77 } // namespace ssl_errors
79 #endif // COMPONENTS_SSL_ERRORS_SSL_ERROR_INFO_H_