namespace Mono.Security.Protocol.Tls
{
- public abstract class SslStreamBase: Stream, IDisposable
+#if INSIDE_SYSTEM
+ internal
+#else
+ public
+#endif
+ abstract class SslStreamBase: Stream, IDisposable
{
private delegate void AsyncHandshakeDelegate(InternalAsyncResult asyncResult, bool fromWrite);
#region Fields
- static ManualResetEvent record_processing = new ManualResetEvent (true);
-
- private const int WaitTimeOut = 5 * 60 * 1000;
+ static ManualResetEvent record_processing = new ManualResetEvent (true);
internal Stream innerStream;
internal MemoryStream inputBuffer;
X509CertificateCollection serverRequestedCertificates);
internal abstract bool OnRemoteCertificateValidation(X509Certificate certificate, int[] errors);
+ internal abstract ValidationResult OnRemoteCertificateValidation2 (Mono.Security.X509.X509CertificateCollection collection);
+ internal abstract bool HaveRemoteValidation2Callback { get; }
internal abstract AsymmetricAlgorithm OnLocalPrivateKeySelection(X509Certificate certificate, string targetHost);
return OnRemoteCertificateValidation(certificate, errors);
}
+ internal ValidationResult RaiseRemoteCertificateValidation2 (Mono.Security.X509.X509CertificateCollection collection)
+ {
+ return OnRemoteCertificateValidation2 (collection);
+ }
+
internal AsymmetricAlgorithm RaiseLocalPrivateKeySelection(
X509Certificate certificate,
string targetHost)
{
asyncResult.SetComplete(preReadSize);
}
- else if (!this.context.ConnectionEnd)
+ else if (!this.context.ReceivedConnectionEnd)
{
// this will read data from the network until we have (at least) one
// record to send back to the caller
if (!dataToReturn && (n > 0))
{
- // there is no record to return to caller and (possibly) more data waiting
- // so continue reading from network (and appending to stream)
- recordStream.Position = recordStream.Length;
- this.innerStream.BeginRead(recbuf, 0, recbuf.Length,
- new AsyncCallback(InternalReadCallback), state);
+ if (context.ReceivedConnectionEnd) {
+ internalResult.SetComplete (0);
+ } else {
+ // there is no record to return to caller and (possibly) more data waiting
+ // so continue reading from network (and appending to stream)
+ recordStream.Position = recordStream.Length;
+ this.innerStream.BeginRead(recbuf, 0, recbuf.Length,
+ new AsyncCallback(InternalReadCallback), state);
+ }
}
else
{
// Always wait until the read is complete
if (!asyncResult.IsCompleted)
{
- if (!asyncResult.AsyncWaitHandle.WaitOne (WaitTimeOut, false))
+ if (!asyncResult.AsyncWaitHandle.WaitOne ())
throw new TlsException (AlertDescription.InternalError, "Couldn't complete EndRead");
}
if (!asyncResult.IsCompleted)
{
- if (!internalResult.AsyncWaitHandle.WaitOne (WaitTimeOut, false))
+ if (!internalResult.AsyncWaitHandle.WaitOne ())
throw new TlsException (AlertDescription.InternalError, "Couldn't complete EndWrite");
}
if (this.innerStream != null)
{
if (this.context.HandshakeState == HandshakeState.Finished &&
- !this.context.ConnectionEnd)
+ !this.context.SentConnectionEnd)
{
- // Write close notify
- this.protocol.SendAlert(AlertDescription.CloseNotify);
+ // Write close notify
+ try {
+ this.protocol.SendAlert(AlertDescription.CloseNotify);
+ } catch {
+ }
}
if (this.ownsStream)