Esempio n. 1
0
        public void Start()
        {
            var endPoint = new IPEndPoint(IPAddress.Parse(_lc.ListenIp), Port);
            var handler  = new ReverseProxyHandler(DestinationWebRoot);

            handler.RewriteHost           = true;
            handler.AddForwardedForHeader = false;
            handler.RemoveExpectHeader    = false;

            if (UseHttps)
            {
                var cert = GetCertificate();

                //string pwd = "password";
                //var suppliers = new[] { "CN=localhost" };
                //var cb = new X509CertBuilder(suppliers, "CN=Middleman.Server.DO_NOT_TRUST", CertStrength.bits_512);
                //X509Certificate2 newcert = cb.MakeCertificate(pwd, "CN=localhost", 5);

                //cb.AddCertToStore(newcert, StoreName.Root, StoreLocation.LocalMachine);

                ////File.WriteAllBytes("cert.pfx", newcert.Export(X509ContentType.Pkcs12, pwd));
                ////File.WriteAllBytes("cert.cer", newcert.Export(X509ContentType.Cert, pwd));

                var server = new SecureMiddlemanServer(endPoint, handler, cert);

                server.Start();
            }
            else
            {
                var server = new MiddlemanServer(endPoint, handler);

                server.Start();
            }


            //Common.Log("UseHttps: " + UseHttps);
            //Common.Log("Post: " + Post);
            //Common.Log("CertSearchString: " + CertSearchString);
            //Common.Log("DestinationWebRoot: " + DestinationWebRoot);
            //Common.Log("Port: " + port);

            //if (!string.IsNullOrWhiteSpace(CertSearchString))
            //{
            //    _serverCertificate = GetCertificate();

            //    Common.Log("Server Certificate: " + (_serverCertificate != null ? _serverCertificate.Subject : "NOT FOUND!"));
            //}
        }
Esempio n. 2
0
        public void Start()
        {
            var endPoint = new IPEndPoint(IPAddress.Parse(_lc.ListenIp), Port);
            var handler = new ReverseProxyHandler(DestinationWebRoot);

            handler.RewriteHost = true;
            handler.AddForwardedForHeader = false;
            handler.RemoveExpectHeader = false;

            if (UseHttps)
            {
                var cert = GetCertificate();

                //string pwd = "password";
                //var suppliers = new[] { "CN=localhost" };
                //var cb = new X509CertBuilder(suppliers, "CN=Middleman.Server.DO_NOT_TRUST", CertStrength.bits_512);
                //X509Certificate2 newcert = cb.MakeCertificate(pwd, "CN=localhost", 5);

                //cb.AddCertToStore(newcert, StoreName.Root, StoreLocation.LocalMachine);

                ////File.WriteAllBytes("cert.pfx", newcert.Export(X509ContentType.Pkcs12, pwd));
                ////File.WriteAllBytes("cert.cer", newcert.Export(X509ContentType.Cert, pwd));

                var server = new SecureMiddlemanServer(endPoint, handler, cert);

                server.Start();
            }
            else
            {
                var server = new MiddlemanServer(endPoint, handler);

                server.Start();
            }

            //Common.Log("UseHttps: " + UseHttps);
            //Common.Log("Post: " + Post);
            //Common.Log("CertSearchString: " + CertSearchString);
            //Common.Log("DestinationWebRoot: " + DestinationWebRoot);
            //Common.Log("Port: " + port);

            //if (!string.IsNullOrWhiteSpace(CertSearchString))
            //{
            //    _serverCertificate = GetCertificate();

            //    Common.Log("Server Certificate: " + (_serverCertificate != null ? _serverCertificate.Subject : "NOT FOUND!"));
            //}
        }