[System]: Fix bug #52508 in HttpListener when doing multiple Https request.
[mono.git] / mcs / class / System / System.Net / HttpConnection.cs
index 885eaf3ea3df14566dcf0a32bf21e653d1314be9..bd465b9ca29004dce302b117a3ca292d87d6cc53 100644 (file)
 #if MONO_SECURITY_ALIAS
 extern alias MonoSecurity;
 #endif
-#if MONO_X509_ALIAS
-extern alias PrebuiltSystem;
-#endif
 
 #if MONO_SECURITY_ALIAS
 using MSI = MonoSecurity::Mono.Security.Interface;
 #else
 using MSI = Mono.Security.Interface;
 #endif
-#if MONO_X509_ALIAS
-using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#else
-using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
-#endif
 
 using System.IO;
 using System.Net.Sockets;
 using System.Text;
 using System.Threading;
+using System.Net.Security;
 using System.Security.Authentication;
 using System.Security.Cryptography;
 using System.Security.Cryptography.X509Certificates;
-using Mono.Net.Security;
 
 namespace System.Net {
        sealed class HttpConnection
@@ -81,7 +73,7 @@ namespace System.Net {
                HttpListener last_listener;
                int [] client_cert_errors;
                X509Certificate2 client_cert;
-               IMonoSslStream ssl_stream;
+               SslStream ssl_stream;
 
                public HttpConnection (Socket sock, EndPointListener epl, bool secure, X509Certificate cert)
                {
@@ -102,12 +94,18 @@ namespace System.Net {
                                        client_cert_errors = new int[] { (int)e };
                                        return true;
                                });
-                               stream = ssl_stream.AuthenticatedStream;
+                               stream = ssl_stream;
                        }
                        timer = new Timer (OnTimeout, null, Timeout.Infinite, Timeout.Infinite);
+                       if (ssl_stream != null)
+                               ssl_stream.AuthenticateAsServer (cert, true, (SslProtocols)ServicePointManager.SecurityProtocol, false);
                        Init ();
                }
 
+               internal SslStream SslStream {
+                       get { return ssl_stream; }
+               }
+
                internal int [] ClientCertificateErrors {
                        get { return client_cert_errors; }
                }
@@ -118,10 +116,6 @@ namespace System.Net {
 
                void Init ()
                {
-                       if (ssl_stream != null) {
-                               ssl_stream.AuthenticateAsServer (cert, true, (SslProtocols)ServicePointManager.SecurityProtocol, false);
-                       }
-
                        context_bound = false;
                        i_stream = null;
                        o_stream = null;