[SslClientStream] Prevent crashes when a connection is closed
[mono.git] / mcs / class / Mono.Security / Mono.Security.Protocol.Tls / SslClientStream.cs
index 08b69d5d6f69c723b84354c4516fd157668b047c..2936122c4bd9d5826363fc35f453beab2145405b 100644 (file)
@@ -586,9 +586,21 @@ namespace Mono.Security.Protocol.Tls
                                        break;
                                }
                        }
+                       catch (TlsException ex)
+                       {
+                               try {
+                                       Exception e = ex;
+                                       this.protocol.SendAlert(ref e);
+                               } catch {
+                               }
+                               negotiate.SetComplete(new IOException("The authentication or decryption has failed.", ex));
+                       }
                        catch (Exception ex)
                        {
-                               this.protocol.SendAlert(ref ex);
+                               try {
+                                       this.protocol.SendAlert(AlertDescription.InternalError);
+                               } catch {
+                               }
                                negotiate.SetComplete(new IOException("The authentication or decryption has failed.", ex));
                        }
                }