2009-11-03 02:25:20 +00:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2019-05-12 18:42:15 +01:00
|
|
|
package trs
|
2009-11-03 02:25:20 +00:00
|
|
|
|
2010-04-27 06:19:04 +01:00
|
|
|
import "strconv"
|
|
|
|
|
|
|
|
type alert uint8
|
2009-11-03 02:25:20 +00:00
|
|
|
|
|
|
|
const (
|
2010-04-27 06:19:04 +01:00
|
|
|
// alert level
|
|
|
|
alertLevelWarning = 1
|
|
|
|
alertLevelError = 2
|
2009-11-03 02:25:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2010-04-27 06:19:04 +01:00
|
|
|
alertCloseNotify alert = 0
|
|
|
|
alertUnexpectedMessage alert = 10
|
|
|
|
alertBadRecordMAC alert = 20
|
|
|
|
alertDecryptionFailed alert = 21
|
|
|
|
alertRecordOverflow alert = 22
|
|
|
|
alertDecompressionFailure alert = 30
|
|
|
|
alertHandshakeFailure alert = 40
|
|
|
|
alertBadCertificate alert = 42
|
|
|
|
alertUnsupportedCertificate alert = 43
|
|
|
|
alertCertificateRevoked alert = 44
|
|
|
|
alertCertificateExpired alert = 45
|
|
|
|
alertCertificateUnknown alert = 46
|
|
|
|
alertIllegalParameter alert = 47
|
|
|
|
alertUnknownCA alert = 48
|
|
|
|
alertAccessDenied alert = 49
|
|
|
|
alertDecodeError alert = 50
|
|
|
|
alertDecryptError alert = 51
|
|
|
|
alertProtocolVersion alert = 70
|
|
|
|
alertInsufficientSecurity alert = 71
|
|
|
|
alertInternalError alert = 80
|
2014-10-16 01:54:04 +01:00
|
|
|
alertInappropriateFallback alert = 86
|
2010-04-27 06:19:04 +01:00
|
|
|
alertUserCanceled alert = 90
|
|
|
|
alertNoRenegotiation alert = 100
|
2017-05-19 00:33:09 +01:00
|
|
|
alertUnsupportedExtension alert = 110
|
2018-03-26 16:56:31 +01:00
|
|
|
alertCertificateRequired alert = 116
|
2016-10-11 18:08:57 +01:00
|
|
|
alertNoApplicationProtocol alert = 120
|
2017-01-16 12:23:17 +00:00
|
|
|
alertSuccess alert = 255 // dummy value returned by unmarshal functions
|
2009-11-03 02:25:20 +00:00
|
|
|
)
|
|
|
|
|
2010-04-27 06:19:04 +01:00
|
|
|
var alertText = map[alert]string{
|
|
|
|
alertCloseNotify: "close notify",
|
|
|
|
alertUnexpectedMessage: "unexpected message",
|
|
|
|
alertBadRecordMAC: "bad record MAC",
|
|
|
|
alertDecryptionFailed: "decryption failed",
|
|
|
|
alertRecordOverflow: "record overflow",
|
|
|
|
alertDecompressionFailure: "decompression failure",
|
|
|
|
alertHandshakeFailure: "handshake failure",
|
|
|
|
alertBadCertificate: "bad certificate",
|
|
|
|
alertUnsupportedCertificate: "unsupported certificate",
|
|
|
|
alertCertificateRevoked: "revoked certificate",
|
|
|
|
alertCertificateExpired: "expired certificate",
|
|
|
|
alertCertificateUnknown: "unknown certificate",
|
|
|
|
alertIllegalParameter: "illegal parameter",
|
|
|
|
alertUnknownCA: "unknown certificate authority",
|
|
|
|
alertAccessDenied: "access denied",
|
|
|
|
alertDecodeError: "error decoding message",
|
|
|
|
alertDecryptError: "error decrypting message",
|
|
|
|
alertProtocolVersion: "protocol version not supported",
|
|
|
|
alertInsufficientSecurity: "insufficient security level",
|
|
|
|
alertInternalError: "internal error",
|
2014-10-16 01:54:04 +01:00
|
|
|
alertInappropriateFallback: "inappropriate fallback",
|
2010-04-27 06:19:04 +01:00
|
|
|
alertUserCanceled: "user canceled",
|
|
|
|
alertNoRenegotiation: "no renegotiation",
|
2016-10-11 18:08:57 +01:00
|
|
|
alertNoApplicationProtocol: "no application protocol",
|
2010-04-27 06:19:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (e alert) String() string {
|
|
|
|
s, ok := alertText[e]
|
|
|
|
if ok {
|
2016-04-12 18:43:44 +01:00
|
|
|
return "tls: " + s
|
2010-04-27 06:19:04 +01:00
|
|
|
}
|
2016-04-12 18:43:44 +01:00
|
|
|
return "tls: alert(" + strconv.Itoa(int(e)) + ")"
|
2009-11-03 02:25:20 +00:00
|
|
|
}
|
2011-10-28 03:42:32 +01:00
|
|
|
|
|
|
|
func (e alert) Error() string {
|
|
|
|
return e.String()
|
|
|
|
}
|