private bool CreateStream(HttpWebRequest request)
{
try
{
System.Net.Sockets.NetworkStream networkStream = new System.Net.Sockets.NetworkStream(this.socket, false);
if (request.Address.Scheme == System.Uri.UriSchemeHttps)
{
this.ssl = true;
WebConnection.EnsureSSLStreamAvailable();
if (!this.reused || this.nstream == null || this.nstream.GetType() != WebConnection.sslStream)
{
byte[] array = null;
if (this.sPoint.UseConnect && !this.CreateTunnel(request, networkStream, out array))
{
return(false);
}
object[] args = new object[]
{
networkStream,
request.ClientCertificates,
request,
array
};
this.nstream = (Stream)Activator.CreateInstance(WebConnection.sslStream, args);
SslClientStream sslClientStream = (SslClientStream)this.nstream;
ServicePointManager.ChainValidationHelper @object = new ServicePointManager.ChainValidationHelper(request);
sslClientStream.ServerCertValidation2 += @object.ValidateChain;
this.certsAvailable = false;
}
}
else
{
this.ssl = false;
this.nstream = networkStream;
}
}
catch (Exception)
{
if (!request.Aborted)
{
this.status = WebExceptionStatus.ConnectFailure;
}
return(false);
}
return(true);
}