summary refs log tree commit diff
path: root/crypto/src/tls/TlsNoCloseNotifyException.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/tls/TlsNoCloseNotifyException.cs')
-rw-r--r--crypto/src/tls/TlsNoCloseNotifyException.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/crypto/src/tls/TlsNoCloseNotifyException.cs b/crypto/src/tls/TlsNoCloseNotifyException.cs
new file mode 100644
index 000000000..8fdfbbfc4
--- /dev/null
+++ b/crypto/src/tls/TlsNoCloseNotifyException.cs
@@ -0,0 +1,21 @@
+using System;
+using System.IO;
+
+namespace Org.BouncyCastle.Tls
+{
+    /// <summary>This exception will be thrown (only) when the connection is closed by the peer without sending a
+    /// <see cref="AlertDescription.close_notify">close_notify</see> warning alert.</summary>
+    /// <remarks>
+    /// If this happens, the TLS protocol cannot rule out truncation of the connection data (potentially
+    /// malicious). It may be possible to check for truncation via some property of a higher level protocol
+    /// built upon TLS, e.g.the Content-Length header for HTTPS.
+    /// </remarks>
+    public class TlsNoCloseNotifyException
+        : EndOfStreamException
+    {
+        public TlsNoCloseNotifyException()
+            : base("No close_notify alert received before connection closed")
+        {
+        }
+    }
+}