Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public void Test()
        {
            var provider = new CertificateProvider(@"C:\Program Files (x86)\Fiddler2\makecert.exe");

            provider.EnsureRootCertificate();
            var certificate = provider.GetCertificateForHost("www.test3.com");
        }