github.com/Hyperledger-TWGC/tjfoc-gm@v1.4.0/gmtls/alert.go (about) 1 /* 2 Copyright Suzhou Tongji Fintech Research Institute 2017 All Rights Reserved. 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 */ 15 16 package gmtls 17 18 import "strconv" 19 20 type alert uint8 21 22 const ( 23 // alert level 24 alertLevelWarning = 1 25 alertLevelError = 2 26 ) 27 28 const ( 29 alertCloseNotify alert = 0 30 alertUnexpectedMessage alert = 10 31 alertBadRecordMAC alert = 20 32 alertDecryptionFailed alert = 21 33 alertRecordOverflow alert = 22 34 alertDecompressionFailure alert = 30 35 alertHandshakeFailure alert = 40 36 alertBadCertificate alert = 42 37 alertUnsupportedCertificate alert = 43 38 alertCertificateRevoked alert = 44 39 alertCertificateExpired alert = 45 40 alertCertificateUnknown alert = 46 41 alertIllegalParameter alert = 47 42 alertUnknownCA alert = 48 43 alertAccessDenied alert = 49 44 alertDecodeError alert = 50 45 alertDecryptError alert = 51 46 alertProtocolVersion alert = 70 47 alertInsufficientSecurity alert = 71 48 alertInternalError alert = 80 49 alertInappropriateFallback alert = 86 50 alertUserCanceled alert = 90 51 alertNoRenegotiation alert = 100 52 alertNoApplicationProtocol alert = 120 53 //GMT0024 54 alertUnspporttedSite2Site alert = 200 55 alertNoArea alert = 201 56 alertUnspportedAreaType alert = 202 57 alertBadIBCParam alert = 203 58 alertUnspportedIBCParam alert = 204 59 alertIdentityNeed alert = 205 60 ) 61 62 var alertText = map[alert]string{ 63 alertCloseNotify: "close notify", 64 alertUnexpectedMessage: "unexpected message", 65 alertBadRecordMAC: "bad record MAC", 66 alertDecryptionFailed: "decryption failed", 67 alertRecordOverflow: "record overflow", 68 alertDecompressionFailure: "decompression failure", 69 alertHandshakeFailure: "handshake failure", 70 alertBadCertificate: "bad certificate", 71 alertUnsupportedCertificate: "unsupported certificate", 72 alertCertificateRevoked: "revoked certificate", 73 alertCertificateExpired: "expired certificate", 74 alertCertificateUnknown: "unknown certificate", 75 alertIllegalParameter: "illegal parameter", 76 alertUnknownCA: "unknown certificate authority", 77 alertAccessDenied: "access denied", 78 alertDecodeError: "error decoding message", 79 alertDecryptError: "error decrypting message", 80 alertProtocolVersion: "protocol version not supported", 81 alertInsufficientSecurity: "insufficient security level", 82 alertInternalError: "internal error", 83 alertInappropriateFallback: "inappropriate fallback", 84 alertUserCanceled: "user canceled", 85 alertNoRenegotiation: "no renegotiation", 86 alertNoApplicationProtocol: "no application protocol", 87 //GMT0024 88 alertUnspporttedSite2Site: "不支持site2site", 89 alertNoArea : "没有保护域", 90 alertUnspportedAreaType : "不支持的保护域类型", 91 alertBadIBCParam : "接收到一个无效的ibc公共参数", 92 alertUnspportedIBCParam : "不支持ibc参数中定义的信息", 93 alertIdentityNeed : "缺少对方的ibc标识", 94 } 95 96 func (e alert) String() string { 97 s, ok := alertText[e] 98 if ok { 99 return "tls: " + s 100 } 101 return "tls: alert(" + strconv.Itoa(int(e)) + ")" 102 } 103 104 func (e alert) Error() string { 105 return e.String() 106 }