Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

84 строки
2.8 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. alertCertificateRequired alert = 116
  37. alertNoApplicationProtocol alert = 120
  38. alertSuccess alert = 255 // dummy value returned by unmarshal functions
  39. )
  40. var alertText = map[alert]string{
  41. alertCloseNotify: "close notify",
  42. alertUnexpectedMessage: "unexpected message",
  43. alertBadRecordMAC: "bad record MAC",
  44. alertDecryptionFailed: "decryption failed",
  45. alertRecordOverflow: "record overflow",
  46. alertDecompressionFailure: "decompression failure",
  47. alertHandshakeFailure: "handshake failure",
  48. alertBadCertificate: "bad certificate",
  49. alertUnsupportedCertificate: "unsupported certificate",
  50. alertCertificateRevoked: "revoked certificate",
  51. alertCertificateExpired: "expired certificate",
  52. alertCertificateUnknown: "unknown certificate",
  53. alertIllegalParameter: "illegal parameter",
  54. alertUnknownCA: "unknown certificate authority",
  55. alertAccessDenied: "access denied",
  56. alertDecodeError: "error decoding message",
  57. alertDecryptError: "error decrypting message",
  58. alertProtocolVersion: "protocol version not supported",
  59. alertInsufficientSecurity: "insufficient security level",
  60. alertInternalError: "internal error",
  61. alertInappropriateFallback: "inappropriate fallback",
  62. alertUserCanceled: "user canceled",
  63. alertNoRenegotiation: "no renegotiation",
  64. alertNoApplicationProtocol: "no application protocol",
  65. }
  66. func (e alert) String() string {
  67. s, ok := alertText[e]
  68. if ok {
  69. return "tls: " + s
  70. }
  71. return "tls: alert(" + strconv.Itoa(int(e)) + ")"
  72. }
  73. func (e alert) Error() string {
  74. return e.String()
  75. }