1
2
3
4
5 package tls
6
7 import "strconv"
8
9
10
11
12
13 type AlertError uint8
14
15 var _ error = AlertError(0)
16
17 func (e AlertError) Error() string {
18 return alert(e).String()
19 }
20
21 type alert uint8
22
23 const (
24
25 alertLevelWarning = 1
26 alertLevelError = 2
27 )
28
29 const (
30 alertCloseNotify alert = 0
31 alertUnexpectedMessage alert = 10
32 alertBadRecordMAC alert = 20
33 alertDecryptionFailed alert = 21
34 alertRecordOverflow alert = 22
35 alertDecompressionFailure alert = 30
36 alertHandshakeFailure alert = 40
37 alertBadCertificate alert = 42
38 alertUnsupportedCertificate alert = 43
39 alertCertificateRevoked alert = 44
40 alertCertificateExpired alert = 45
41 alertCertificateUnknown alert = 46
42 alertIllegalParameter alert = 47
43 alertUnknownCA alert = 48
44 alertAccessDenied alert = 49
45 alertDecodeError alert = 50
46 alertDecryptError alert = 51
47 alertExportRestriction alert = 60
48 alertProtocolVersion alert = 70
49 alertInsufficientSecurity alert = 71
50 alertInternalError alert = 80
51 alertInappropriateFallback alert = 86
52 alertUserCanceled alert = 90
53 alertNoRenegotiation alert = 100
54 alertMissingExtension alert = 109
55 alertUnsupportedExtension alert = 110
56 alertCertificateUnobtainable alert = 111
57 alertUnrecognizedName alert = 112
58 alertBadCertificateStatusResponse alert = 113
59 alertBadCertificateHashValue alert = 114
60 alertUnknownPSKIdentity alert = 115
61 alertCertificateRequired alert = 116
62 alertNoApplicationProtocol alert = 120
63 alertECHRequired alert = 121
64 )
65
66 var alertText = map[alert]string{
67 alertCloseNotify: "close notify",
68 alertUnexpectedMessage: "unexpected message",
69 alertBadRecordMAC: "bad record MAC",
70 alertDecryptionFailed: "decryption failed",
71 alertRecordOverflow: "record overflow",
72 alertDecompressionFailure: "decompression failure",
73 alertHandshakeFailure: "handshake failure",
74 alertBadCertificate: "bad certificate",
75 alertUnsupportedCertificate: "unsupported certificate",
76 alertCertificateRevoked: "revoked certificate",
77 alertCertificateExpired: "expired certificate",
78 alertCertificateUnknown: "unknown certificate",
79 alertIllegalParameter: "illegal parameter",
80 alertUnknownCA: "unknown certificate authority",
81 alertAccessDenied: "access denied",
82 alertDecodeError: "error decoding message",
83 alertDecryptError: "error decrypting message",
84 alertExportRestriction: "export restriction",
85 alertProtocolVersion: "protocol version not supported",
86 alertInsufficientSecurity: "insufficient security level",
87 alertInternalError: "internal error",
88 alertInappropriateFallback: "inappropriate fallback",
89 alertUserCanceled: "user canceled",
90 alertNoRenegotiation: "no renegotiation",
91 alertMissingExtension: "missing extension",
92 alertUnsupportedExtension: "unsupported extension",
93 alertCertificateUnobtainable: "certificate unobtainable",
94 alertUnrecognizedName: "unrecognized name",
95 alertBadCertificateStatusResponse: "bad certificate status response",
96 alertBadCertificateHashValue: "bad certificate hash value",
97 alertUnknownPSKIdentity: "unknown PSK identity",
98 alertCertificateRequired: "certificate required",
99 alertNoApplicationProtocol: "no application protocol",
100 alertECHRequired: "encrypted client hello required",
101 }
102
103 func (e alert) String() string {
104 s, ok := alertText[e]
105 if ok {
106 return "tls: " + s
107 }
108 return "tls: alert(" + strconv.Itoa(int(e)) + ")"
109 }
110
111 func (e alert) Error() string {
112 return e.String()
113 }
114
View as plain text