internal Stream CreateStream(byte[] buffer) { #if SECURITY_DEP sslStream = provider.CreateSslStream(networkStream, false, settings); try { var host = request.Host; if (!string.IsNullOrEmpty(host)) { var pos = host.IndexOf(':'); if (pos > 0) { host = host.Substring(0, pos); } } sslStream.AuthenticateAsClient( host, request.ClientCertificates, (SslProtocols)ServicePointManager.SecurityProtocol, ServicePointManager.CheckCertificateRevocationList); status = WebExceptionStatus.Success; } catch { status = WebExceptionStatus.SecureChannelFailure; throw; } finally { if (CertificateValidationFailed) { status = WebExceptionStatus.TrustFailure; } if (status == WebExceptionStatus.Success) { request.ServicePoint.UpdateClientCertificate(sslStream.InternalLocalCertificate); } else { request.ServicePoint.UpdateClientCertificate(null); sslStream = null; } } try { if (buffer != null) { sslStream.Write(buffer, 0, buffer.Length); } } catch { status = WebExceptionStatus.SendFailure; sslStream = null; throw; } return(sslStream.AuthenticatedStream); #else throw new PlatformNotSupportedException(EXCEPTION_MESSAGE); #endif }
internal Stream CreateStream(byte[] buffer) { sslStream = provider.CreateSslStream(networkStream, false, settings); try { sslStream.AuthenticateAsClient( request.Host, request.ClientCertificates, (SslProtocols)ServicePointManager.SecurityProtocol, ServicePointManager.CheckCertificateRevocationList); status = WebExceptionStatus.Success; } catch (Exception) { status = WebExceptionStatus.SecureChannelFailure; throw; } finally { if (CertificateValidationFailed) { status = WebExceptionStatus.TrustFailure; } if (status == WebExceptionStatus.Success) { request.ServicePoint.UpdateClientCertificate(sslStream.InternalLocalCertificate); } else { request.ServicePoint.UpdateClientCertificate(null); sslStream = null; } } try { if (buffer != null) { sslStream.Write(buffer, 0, buffer.Length); } } catch { status = WebExceptionStatus.SendFailure; sslStream = null; throw; } return(sslStream.AuthenticatedStream); }
internal Stream CreateStream (byte[] buffer) { sslStream = provider.CreateSslStream (networkStream, false, settings); try { sslStream.AuthenticateAsClient ( request.Address.Host, request.ClientCertificates, (SslProtocols)ServicePointManager.SecurityProtocol, ServicePointManager.CheckCertificateRevocationList); status = WebExceptionStatus.Success; } catch (Exception ex) { status = WebExceptionStatus.SecureChannelFailure; throw; } finally { if (CertificateValidationFailed) status = WebExceptionStatus.TrustFailure; if (status == WebExceptionStatus.Success) request.ServicePoint.UpdateClientCertificate (sslStream.InternalLocalCertificate); else { request.ServicePoint.UpdateClientCertificate (null); sslStream = null; } } try { if (buffer != null) sslStream.Write (buffer, 0, buffer.Length); } catch { status = WebExceptionStatus.SendFailure; sslStream = null; throw; } return sslStream.AuthenticatedStream; }
public void AuthenticateAsClient(string targetHost) { Impl.AuthenticateAsClient(targetHost); }