TlsFatalAlertReceived.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.Runtime.Serialization;
  5. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Tls
  6. {
  7. [Serializable]
  8. public class TlsFatalAlertReceived
  9. : TlsException
  10. {
  11. protected readonly byte m_alertDescription;
  12. public TlsFatalAlertReceived(short alertDescription)
  13. : base(Tls.AlertDescription.GetText(alertDescription))
  14. {
  15. if (!TlsUtilities.IsValidUint8(alertDescription))
  16. throw new ArgumentOutOfRangeException(nameof(alertDescription));
  17. m_alertDescription = (byte)alertDescription;
  18. }
  19. protected TlsFatalAlertReceived(SerializationInfo info, StreamingContext context)
  20. : base(info, context)
  21. {
  22. m_alertDescription = info.GetByte("alertDescription");
  23. }
  24. public override void GetObjectData(SerializationInfo info, StreamingContext context)
  25. {
  26. base.GetObjectData(info, context);
  27. info.AddValue("alertDescription", m_alertDescription);
  28. }
  29. public virtual short AlertDescription
  30. {
  31. get { return m_alertDescription; }
  32. }
  33. }
  34. }
  35. #pragma warning restore
  36. #endif