File: error_info.h

package info (click to toggle)
chromium 120.0.6099.224-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,112,112 kB
  • sloc: cpp: 32,907,025; ansic: 8,148,123; javascript: 3,679,536; python: 2,031,248; asm: 959,718; java: 804,675; xml: 617,256; sh: 111,417; objc: 100,835; perl: 88,443; cs: 53,032; makefile: 29,579; fortran: 24,137; php: 21,162; tcl: 21,147; sql: 20,809; ruby: 17,735; pascal: 12,864; yacc: 8,045; lisp: 3,388; lex: 1,323; ada: 727; awk: 329; jsp: 267; csh: 117; exp: 43; sed: 37
file content (82 lines) | stat: -rw-r--r-- 2,607 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_SSL_ERRORS_ERROR_INFO_H_
#define COMPONENTS_SSL_ERRORS_ERROR_INFO_H_

#include <string>
#include <vector>

#include "net/cert/cert_status_flags.h"
#include "net/cert/x509_certificate.h"

class GURL;

namespace ssl_errors {

// This class describes an error that happened while showing a page over SSL.
// An ErrorInfo object only exists on the UI thread and only contains
// information about an error (type of error and text details).
// Note no DISALLOW_COPY_AND_ASSIGN as we want the copy constructor.
class ErrorInfo {
 public:
  // This enum is being histogrammed; please only add new values at the end.
  enum ErrorType {
    CERT_COMMON_NAME_INVALID = 0,
    CERT_DATE_INVALID = 1,
    CERT_AUTHORITY_INVALID = 2,
    CERT_CONTAINS_ERRORS = 3,
    CERT_NO_REVOCATION_MECHANISM = 4,
    CERT_UNABLE_TO_CHECK_REVOCATION = 5,
    CERT_REVOKED = 6,
    CERT_INVALID = 7,
    CERT_WEAK_SIGNATURE_ALGORITHM = 8,
    CERT_WEAK_KEY = 9,
    CERT_NAME_CONSTRAINT_VIOLATION = 10,
    UNKNOWN = 11,
    // CERT_WEAK_KEY_DH = 12,
    CERT_PINNED_KEY_MISSING = 13,
    CERT_VALIDITY_TOO_LONG = 14,
    CERTIFICATE_TRANSPARENCY_REQUIRED = 15,
    CERT_SYMANTEC_LEGACY = 16,
    CERT_KNOWN_INTERCEPTION_BLOCKED = 17,
    LEGACY_TLS = 18,
    END_OF_ENUM
  };

  virtual ~ErrorInfo();

  // Converts a network error code to an ErrorType.
  static ErrorType NetErrorToErrorType(int net_error);

  static ErrorInfo CreateError(ErrorType error_type,
                               net::X509Certificate* cert,
                               const GURL& request_url);

  // Populates the specified |errors| vector with the errors contained in
  // |cert_status| for |cert|.  Returns the number of errors found.
  // Callers only interested in the error count can pass NULL for |errors|.
  static void GetErrorsForCertStatus(
      const scoped_refptr<net::X509Certificate>& cert,
      net::CertStatus cert_status,
      const GURL& url,
      std::vector<ErrorInfo>* errors);

  // A description of the error.
  const std::u16string& details() const { return details_; }

  // A short message describing the error (1 line).
  const std::u16string& short_description() const { return short_description_; }

 private:
  ErrorInfo(const std::u16string& details,
            const std::u16string& short_description);

  std::u16string details_;
  std::u16string short_description_;
};

}  // namespace ssl_errors

#endif  // COMPONENTS_SSL_ERRORS_ERROR_INFO_H_