Exemplo n.º 1
0
        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
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public void Write(byte[] buffer)
 {
     Impl.Write(buffer);
 }
Exemplo n.º 4
0
 public override void Write(byte[] buffer)
 {
     Impl.Write(buffer);
 }