From 68c795fe81277f73aeb90d8ad4c6f4305f32c906 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Mon, 12 Jul 2021 15:15:36 +0700 Subject: Port of new TLS API from bc-java --- crypto/src/tls/TlsFatalAlert.cs | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 crypto/src/tls/TlsFatalAlert.cs (limited to 'crypto/src/tls/TlsFatalAlert.cs') diff --git a/crypto/src/tls/TlsFatalAlert.cs b/crypto/src/tls/TlsFatalAlert.cs new file mode 100644 index 000000000..9f0ea8f30 --- /dev/null +++ b/crypto/src/tls/TlsFatalAlert.cs @@ -0,0 +1,46 @@ +using System; + +namespace Org.BouncyCastle.Tls +{ + public class TlsFatalAlert + : TlsException + { + private static string GetMessage(short alertDescription, string detailMessage) + { + string msg = Tls.AlertDescription.GetText(alertDescription); + if (null != detailMessage) + { + msg += "; " + detailMessage; + } + return msg; + } + + protected readonly short m_alertDescription; + + public TlsFatalAlert(short alertDescription) + : this(alertDescription, (string)null) + { + } + + public TlsFatalAlert(short alertDescription, string detailMessage) + : this(alertDescription, detailMessage, null) + { + } + + public TlsFatalAlert(short alertDescription, Exception alertCause) + : this(alertDescription, null, alertCause) + { + } + + public TlsFatalAlert(short alertDescription, string detailMessage, Exception alertCause) + : base(GetMessage(alertDescription, detailMessage), alertCause) + { + this.m_alertDescription = alertDescription; + } + + public virtual short AlertDescription + { + get { return m_alertDescription; } + } + } +} -- cgit 1.4.1