public HttpConnection(ILogger logger, Socket sock, EndPointListener epl, bool secure, X509Certificate cert, string connectionId)
{
_connectionId = connectionId;
_logger = logger;
this.sock = sock;
this.epl = epl;
this.secure = secure;
this.cert = cert;
this.SetSocketTimeout(sock);
if (secure == false)
{
stream = new NetworkStream(sock, false);
}
else
{
//ssl_stream = epl.Listener.CreateSslStream(new NetworkStream(sock, false), false, (t, c, ch, e) =>
//{
// if (c == null)
// return true;
// var c2 = c as X509Certificate2;
// if (c2 == null)
// c2 = new X509Certificate2(c.GetRawCertData());
// client_cert = c2;
// client_cert_errors = new int[] { (int)e };
// return true;
//});
//stream = ssl_stream.AuthenticatedStream;
ssl_stream = new SslStream(new NetworkStream(sock, false), false);
ssl_stream.AuthenticateAsServer(cert);
stream = ssl_stream;
}
timer = new ResumableTimer(OnTimeout);
Init();
}