Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

82 rader
2.7 KiB

  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. package tls
  5. import "strconv"
  6. type alert uint8
  7. const (
  8. // alert level
  9. alertLevelWarning = 1
  10. alertLevelError = 2
  11. )
  12. const (
  13. alertCloseNotify alert = 0
  14. alertUnexpectedMessage alert = 10
  15. alertBadRecordMAC alert = 20
  16. alertDecryptionFailed alert = 21
  17. alertRecordOverflow alert = 22
  18. alertDecompressionFailure alert = 30
  19. alertHandshakeFailure alert = 40
  20. alertBadCertificate alert = 42
  21. alertUnsupportedCertificate alert = 43
  22. alertCertificateRevoked alert = 44
  23. alertCertificateExpired alert = 45
  24. alertCertificateUnknown alert = 46
  25. alertIllegalParameter alert = 47
  26. alertUnknownCA alert = 48
  27. alertAccessDenied alert = 49
  28. alertDecodeError alert = 50
  29. alertDecryptError alert = 51
  30. alertProtocolVersion alert = 70
  31. alertInsufficientSecurity alert = 71
  32. alertInternalError alert = 80
  33. alertInappropriateFallback alert = 86
  34. alertUserCanceled alert = 90
  35. alertNoRenegotiation alert = 100
  36. alertNoApplicationProtocol alert = 120
  37. )
  38. var alertText = map[alert]string{
  39. alertCloseNotify: "close notify",
  40. alertUnexpectedMessage: "unexpected message",
  41. alertBadRecordMAC: "bad record MAC",
  42. alertDecryptionFailed: "decryption failed",
  43. alertRecordOverflow: "record overflow",
  44. alertDecompressionFailure: "decompression failure",
  45. alertHandshakeFailure: "handshake failure",
  46. alertBadCertificate: "bad certificate",
  47. alertUnsupportedCertificate: "unsupported certificate",
  48. alertCertificateRevoked: "revoked certificate",
  49. alertCertificateExpired: "expired certificate",
  50. alertCertificateUnknown: "unknown certificate",
  51. alertIllegalParameter: "illegal parameter",
  52. alertUnknownCA: "unknown certificate authority",
  53. alertAccessDenied: "access denied",
  54. alertDecodeError: "error decoding message",
  55. alertDecryptError: "error decrypting message",
  56. alertProtocolVersion: "protocol version not supported",
  57. alertInsufficientSecurity: "insufficient security level",
  58. alertInternalError: "internal error",
  59. alertInappropriateFallback: "inappropriate fallback",
  60. alertUserCanceled: "user canceled",
  61. alertNoRenegotiation: "no renegotiation",
  62. alertNoApplicationProtocol: "no application protocol",
  63. }
  64. func (e alert) String() string {
  65. s, ok := alertText[e]
  66. if ok {
  67. return "tls: " + s
  68. }
  69. return "tls: alert(" + strconv.Itoa(int(e)) + ")"
  70. }
  71. func (e alert) Error() string {
  72. return e.String()
  73. }