async public static Task <ProxySslRequest> For(ProxyRequest wrapperRequest, IRequestInspector wrapperRequestInspector)
        {
            if (_certProvider == null)
            {
                _certProvider = new CertificateProvider(MakeCertPath);
                _certProvider.EnsureRootCertificate();
            }

            var sslRequest = new ProxySslRequest
            {
                WrapperRequest = wrapperRequest,
                ClientPid      = wrapperRequest.ClientPid,
                ClientSocket   = wrapperRequest.ClientSocket,
                ClientStream   = wrapperRequest.ClientStream
            };

            if (wrapperRequestInspector != null)
            {
                wrapperRequestInspector.OnTransferredToSecureRequest(sslRequest);
            }

            var hostName = sslRequest.GetHostName();

            sslRequest._hostCert = _certProvider.GetCertificateForHost(hostName);

            var clientSsslStream = new SslStream(wrapperRequest.ClientStream, true, RemoteCertificateValidator, sslRequest.LocalCertificateSelector);
            await clientSsslStream.AuthenticateAsServerAsync(sslRequest._hostCert);

            sslRequest.SecureClientStream = clientSsslStream;

            sslRequest.ReadPrologue();

            return(sslRequest);
        }
Example #2
0
        async public static Task<ProxySslRequest> For(ProxyRequest wrapperRequest, IRequestInspector wrapperRequestInspector)
        {
            if (_certProvider == null)
            {
                _certProvider = new CertificateProvider(MakeCertPath);
                _certProvider.EnsureRootCertificate();
            }

            var sslRequest = new ProxySslRequest
                {
                    WrapperRequest = wrapperRequest,
                    ClientPid = wrapperRequest.ClientPid,
                    ClientSocket = wrapperRequest.ClientSocket,
                    ClientStream = wrapperRequest.ClientStream
                };

            if (wrapperRequestInspector != null)
                wrapperRequestInspector.OnTransferredToSecureRequest(sslRequest);

            var hostName = sslRequest.GetHostName();
            sslRequest._hostCert = _certProvider.GetCertificateForHost(hostName);

            var clientSsslStream = new SslStream(wrapperRequest.ClientStream, true, RemoteCertificateValidator, sslRequest.LocalCertificateSelector);
            await clientSsslStream.AuthenticateAsServerAsync(sslRequest._hostCert);
            sslRequest.SecureClientStream = clientSsslStream;

            sslRequest.ReadPrologue();

            return sslRequest;
        }
Example #3
0
        async public static Task<ProxyResponse> From(Socket socket, Stream stream, IRequestInspector requestInspector)
        {
            var response = new ProxyResponse();

            response.RemoteSocket = socket;
            response.RemoteStream = stream;

            requestInspector.OnResponseBegun(response);

            await response.ReadPrologue();

            await response.ReadContent();

            return response;
        }
Example #4
0
        async public static Task <ProxyResponse> From(Socket socket, Stream stream, IRequestInspector requestInspector)
        {
            var response = new ProxyResponse();

            response.RemoteSocket = socket;
            response.RemoteStream = stream;

            requestInspector.OnResponseBegun(response);

            await response.ReadPrologue();

            await response.ReadContent();

            return(response);
        }
Example #5
0
 public void RegisterInspector(IRequestInspector requestInspector)
 {
     _requestInspector = requestInspector;
 }
Example #6
0
 public void RegisterInspector(IRequestInspector requestInspector)
 {
     _requestInspector = requestInspector;
 }