Repository: mitmproxy/mitmproxy

Issue:
Installation error in Windows 8
Hi,
I'm trying to install mitmproxy. My OS is Windows 8, 64 bit. Python is 2.7.10 for 64 bit.

I'm running the command prompt in 'Administrative' mode, granting permission to Administrator for all Files and Folders.My command and the generated error logs are as follow:

```
pip install mitmproxy
--skipping success logs----following are error logs---
    Installed c:\users\humaira\appdata\local\temp\easy_install-sd_aqy\cryptograp
hy-0.9.1\.eggs\pycparser-2.14-py2.7.egg
    no previously-included directories found matching 'docs\_build'
    warning: no previously-included files matching '*' found under directory 've
ctors'
    _Cryptography_cffi_a269d620xd5c405b7.c
    src\cryptography\hazmat\bindings\__pycache__\_Cryptography_cffi_a269d620xd5c
405b7.c(217) : fatal error C1083: Cannot open include file: 'openssl/aes.h': No
such file or directory
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "c:\users\humaira\appdata\local\temp\pip-build-n4tzb8\netlib\setup.py
", line 87, in <module>
        "install": CFFIInstall,
      File "C:\Python27\lib\distutils\core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "C:\Python27\lib\site-packages\setuptools\dist.py", line 268, in __in
it__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "C:\Python27\lib\site-packages\setuptools\dist.py", line 313, in fetc
h_build_eggs
        replace_conflicting=True,
      File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 830,
in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 1075,
 in best_match
        return self.obtain(req, installer)
      File "C:\Python27\lib\site-packages\pkg_resources\__init__.py", line 1087,
 in obtain
        return installer(requirement)
      File "C:\Python27\lib\site-packages\setuptools\dist.py", line 380, in fetc
h_build_egg
        return cmd.easy_install(req)
      File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", l
ine 633, in easy_install
        rmtree(tmpdir)
      File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", l
ine 2197, in rmtree
        rmtree(fullname, ignore_errors, onerror)
      File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", l
ine 2197, in rmtree
        rmtree(fullname, ignore_errors, onerror)
      File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", l
ine 2197, in rmtree
        rmtree(fullname, ignore_errors, onerror)
      File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", l
ine 2202, in rmtree
        onerror(os.remove, fullname, sys.exc_info())
      File "C:\Python27\lib\site-packages\setuptools\command\easy_install.py", l
ine 1609, in auto_chmod
        return func(arg)
    WindowsError: [Error 5] Access is denied: 'c:\\users\\humaira\\appdata\\loca
l\\temp\\easy_install-sd_aqy\\cryptography-0.9.1\\.eggs\\cffi-1.1.2-py2.7-win-am
d64.egg\\_cffi_backend.pyd'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\humaira\
appdata\local\temp\pip-build-n4tzb8\netlib
```

I've granted permission to temp folder, but still it's giving the error. To me, it seems like the error starts from here:
"fatal error C1083: Cannot open include file: 'openssl/aes.h': No
such file or directory"

Any suggestions/comments?? Thanks in advance.



Discussion:
Hi there. We've just uploaded a wheel package for 32-bit Python on Windows that smooths this over by including pre-compiled dependencies. We should have a 64-bit build up soon too.

Hi,
Thanks for the update! Finally, I've been able to install it!!

refs mitmproxy/netlib/issues/68


Resolving patch:
diff --git a/libmproxy/proxy/config.py b/libmproxy/proxy/config.py
--- a/libmproxy/proxy/config.py
+++ b/libmproxy/proxy/config.py
@@ -48,7 +48,6 @@ def __init__(
             ciphers_client=None,
             ciphers_server=None,
             certs=[],
-            certforward=False,
             ssl_version_client=tcp.SSL_DEFAULT_METHOD,
             ssl_version_server=tcp.SSL_DEFAULT_METHOD,
             ssl_ports=TRANSPARENT_SSL_PORTS,
@@ -91,7 +90,6 @@ def __init__(
             CONF_BASENAME)
         for spec, cert in certs:
             self.certstore.add_cert_file(spec, cert)
-        self.certforward = certforward
         self.ssl_ports = ssl_ports
 
         if isinstance(ssl_version_client, int):
@@ -202,7 +200,6 @@ def process_proxy_options(parser, options):
         ciphers_client=options.ciphers_client,
         ciphers_server=options.ciphers_server,
         certs=certs,
-        certforward=options.certforward,
         ssl_version_client=options.ssl_version_client,
         ssl_version_server=options.ssl_version_server,
         ssl_ports=ssl_ports,
@@ -225,11 +222,6 @@ def ssl_option_group(parser):
         'it is used, else the default key in the conf dir is used. '
         'The PEM file should contain the full certificate chain, with the leaf certificate as the first entry. '
         'Can be passed multiple times.')
-    group.add_argument(
-        "--cert-forward", action="store_true",
-        dest="certforward", default=False,
-        help="Simply forward SSL certificates from upstream."
-    )
     group.add_argument(
         "--ciphers-client", action="store",
         type=str, dest="ciphers_client", default=None,
diff --git a/libmproxy/proxy/server.py b/libmproxy/proxy/server.py
--- a/libmproxy/proxy/server.py
+++ b/libmproxy/proxy/server.py
@@ -303,29 +303,25 @@ def log(self, msg, level, subs=()):
         self.channel.tell("log", Log(msg, level))
 
     def find_cert(self):
-        if self.config.certforward and self.server_conn.ssl_established:
-            return self.server_conn.cert, self.config.certstore.gen_pkey(
-                self.server_conn.cert), None
-        else:
-            host = self.server_conn.address.host
-            sans = []
-            if self.server_conn.ssl_established and (
-                    not self.config.no_upstream_cert):
-                upstream_cert = self.server_conn.cert
-                sans.extend(upstream_cert.altnames)
-                if upstream_cert.cn:
-                    sans.append(host)
-                    host = upstream_cert.cn.decode("utf8").encode("idna")
-            if self.server_conn.sni:
-                sans.append(self.server_conn.sni)
-            # for ssl spoof mode
-            if hasattr(self.client_conn, "sni"):
-                sans.append(self.client_conn.sni)
-
-            ret = self.config.certstore.get_cert(host, sans)
-            if not ret:
-                raise ProxyError(502, "Unable to generate dummy cert.")
-            return ret
+        host = self.server_conn.address.host
+        sans = []
+        if self.server_conn.ssl_established and (
+                not self.config.no_upstream_cert):
+            upstream_cert = self.server_conn.cert
+            sans.extend(upstream_cert.altnames)
+            if upstream_cert.cn:
+                sans.append(host)
+                host = upstream_cert.cn.decode("utf8").encode("idna")
+        if self.server_conn.sni:
+            sans.append(self.server_conn.sni)
+        # for ssl spoof mode
+        if hasattr(self.client_conn, "sni"):
+            sans.append(self.client_conn.sni)
+
+        ret = self.config.certstore.get_cert(host, sans)
+        if not ret:
+            raise ProxyError(502, "Unable to generate dummy cert.")
+        return ret
 
     def handle_sni(self, connection):
         """


Test patch:
diff --git a/test/test_server.py b/test/test_server.py
--- a/test/test_server.py
+++ b/test/test_server.py
@@ -757,14 +757,6 @@ def test_incomplete(self):
         assert self.pathod("200").status_code == 502
 
 
-class TestCertForward(tservers.HTTPProxTest):
-    certforward = True
-    ssl = True
-
-    def test_app_err(self):
-        tutils.raises("handshake error", self.pathod, "200:b@100")
-
-
 class TestUpstreamProxy(tservers.HTTPUpstreamProxTest, CommonMixin, AppMixin):
     ssl = False
 
diff --git a/test/tservers.py b/test/tservers.py
--- a/test/tservers.py
+++ b/test/tservers.py
@@ -89,7 +89,6 @@ class ProxTestBase(object):
     no_upstream_cert = False
     authenticator = None
     masterclass = TestMaster
-    certforward = False
 
     @classmethod
     def setupAll(cls):
@@ -131,7 +130,6 @@ def get_proxy_config(cls):
             no_upstream_cert = cls.no_upstream_cert,
             cadir = cls.cadir,
             authenticator = cls.authenticator,
-            certforward = cls.certforward,
             ssl_ports=([cls.server.port, cls.server2.port] if cls.ssl else []),
             clientcerts = tutils.test_data.path("data/clientcert") if cls.clientcerts else None
         )