Index: Mono.Security.Protocol.Tls/SslClientStream.cs =================================================================== --- Mono.Security.Protocol.Tls/SslClientStream.cs (revision 57892) +++ Mono.Security.Protocol.Tls/SslClientStream.cs (working copy) @@ -254,13 +254,17 @@ internal override void OnNegotiateHandshakeCallback(IAsyncResult asyncResult) { +int n = 0; this.protocol.EndSendRecord(asyncResult); - +Console.WriteLine ("{0} {1} Waiting for HandshakeType.ServerHelloDone", DateTime.UtcNow, Thread.CurrentThread.GetHashCode ()); // Read server response while (this.context.LastHandshakeMsg != HandshakeType.ServerHelloDone) { // Read next record - this.protocol.ReceiveRecord(this.innerStream); + if (this.protocol.ReceiveRecord (this.innerStream) == null) { + throw new TlsException ("Communication with host ended."); + } +Console.WriteLine ("{0} {1} OnNegotiateHandshakeCallback (a) {2} {3}", DateTime.UtcNow, Thread.CurrentThread.GetHashCode (), n++, context.LastHandshakeMsg); } // Send client certificate if requested @@ -296,14 +300,18 @@ // Send Cipher Spec protocol this.protocol.SendChangeCipherSpec(); - +n = 0; +Console.WriteLine ("{0} {1} Waiting for HandshakeType.Finished", DateTime.UtcNow, Thread.CurrentThread.GetHashCode ()); // Read record until server finished is received while (this.context.HandshakeState != HandshakeState.Finished) { // If all goes well this will process messages: // Change Cipher Spec // Server finished - this.protocol.ReceiveRecord(this.innerStream); + if (this.protocol.ReceiveRecord (this.innerStream) == null) { + throw new TlsException ("Communication with host ended."); + } +Console.WriteLine ("{0} {1} OnNegotiateHandshakeCallback (b) {2} {3}", DateTime.UtcNow, Thread.CurrentThread.GetHashCode (), n++, context.LastHandshakeMsg); } // Clear Key Info