...

Source file src/crypto/tls/alert.go

Documentation: crypto/tls

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

View as plain text