Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I input “mitproxy”in commands, it is show 'module' object has no attribute 'TLSv1_2_METHOD' #705

Closed
cryingDream94 opened this issue Aug 3, 2015 · 37 comments

Comments

@cryingDream94
Copy link

@cryingDream94 cryingDream94 commented Aug 3, 2015

➜  ~  mitmproxy
Traceback (most recent call last):
  File "/usr/local/bin/mitmproxy", line 9, in <module>
    load_entry_point('mitmproxy==0.13.1', 'console_scripts', 'mitmproxy')()
  File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 337, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2311, in load_entry_point
    return ep.load()
  File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2017, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/Library/Python/2.7/site-packages/libmproxy/main.py", line 7, in <module>
    from . import version, cmdline
  File "/Library/Python/2.7/site-packages/libmproxy/cmdline.py", line 6, in <module>
    from . import filt, utils, version
  File "/Library/Python/2.7/site-packages/libmproxy/filt.py", line 38, in <module>
    from .protocol.http import decoded
  File "/Library/Python/2.7/site-packages/libmproxy/protocol/__init__.py", line 1, in <module>
    from .primitives import *
  File "/Library/Python/2.7/site-packages/libmproxy/protocol/primitives.py", line 4, in <module>
    import netlib.tcp
  File "/Library/Python/2.7/site-packages/netlib/tcp.py", line 26, in <module>
    'TLSv1.2': SSL.TLSv1_2_METHOD,
AttributeError: 'module' object has no attribute 'TLSv1_2_METHOD'
@Kriechi

This comment has been minimized.

Copy link
Member

@Kriechi Kriechi commented Aug 3, 2015

Please make sure your dependencies are all fulfilled, otherwise you get above mentioned error.
pyOpenSSL>=0.15.1
cryptography>=0.9
You can update these two with pip install --upgrade ...

@Kriechi Kriechi closed this Aug 3, 2015
@cryingDream94

This comment has been minimized.

Copy link
Author

@cryingDream94 cryingDream94 commented Aug 3, 2015

➜ sudo pip install cryptography==0.9
The directory '/Users/mengxiangfeng/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/mengxiangfeng/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied (use --upgrade to upgrade): cryptography==0.9 in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): idna in /Library/Python/2.7/site-packages (from cryptography==0.9)
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in /Library/Python/2.7/site-packages (from cryptography==0.9)
Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in /Library/Python/2.7/site-packages (from cryptography==0.9)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from cryptography==0.9)
Requirement already satisfied (use --upgrade to upgrade): enum34 in /Library/Python/2.7/site-packages (from cryptography==0.9)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in /Library/Python/2.7/site-packages (from cryptography==0.9)
Requirement already satisfied (use --upgrade to upgrade): cffi>=0.8 in /Library/Python/2.7/site-packages (from cryptography==0.9)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /Library/Python/2.7/site-packages (from cffi>=0.8->cryptography==0.9)

➜pip install pyOpenSSL==0.15.1
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL==0.15.1 in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /Library/Python/2.7/site-packages (from pyOpenSSL==0.15.1)
Requirement already satisfied (use --upgrade to upgrade): cryptography>=0.7 in /Library/Python/2.7/site-packages (from pyOpenSSL==0.15.1)
Requirement already satisfied (use --upgrade to upgrade): idna in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL==0.15.1)
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL==0.15.1)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from cryptography>=0.7->pyOpenSSL==0.15.1)
Requirement already satisfied (use --upgrade to upgrade): enum34 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL==0.15.1)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL==0.15.1)
Requirement already satisfied (use --upgrade to upgrade): cffi>=0.8 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL==0.15.1)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /Library/Python/2.7/site-packages (from cffi>=0.8->cryptography>=0.7->pyOpenSSL==0.15.1)

➜ ~ mitmproxy
Traceback (most recent call last):
File "/usr/local/bin/mitmproxy", line 9, in
load_entry_point('mitmproxy==0.13.1', 'console_scripts', 'mitmproxy')()
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2311, in load_entry_point
return ep.load()
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2017, in load
entry = import(self.module_name, globals(),globals(), ['name'])
File "/Library/Python/2.7/site-packages/libmproxy/main.py", line 7, in
from . import version, cmdline
File "/Library/Python/2.7/site-packages/libmproxy/cmdline.py", line 6, in
from . import filt, utils, version
File "/Library/Python/2.7/site-packages/libmproxy/filt.py", line 38, in
from .protocol.http import decoded
File "/Library/Python/2.7/site-packages/libmproxy/protocol/init.py", line 1, in
from .primitives import *
File "/Library/Python/2.7/site-packages/libmproxy/protocol/primitives.py", line 4, in
import netlib.tcp
File "/Library/Python/2.7/site-packages/netlib/tcp.py", line 26, in
'TLSv1.2': SSL.TLSv1_2_METHOD,
AttributeError: 'module' object has no attribute 'TLSv1_2_METHOD'
➜ ~

@Kriechi

This comment has been minimized.

Copy link
Member

@Kriechi Kriechi commented Aug 3, 2015

very strange...

Could you please check which OpenSSL version number is reported?

import OpenSSL
OpenSSL.SSL.OPENSSL_VERSION_NUMBER
@cryingDream94

This comment has been minimized.

Copy link
Author

@cryingDream94 cryingDream94 commented Aug 3, 2015

➜ ~ OpenSSL version
OpenSSL 0.9.8zd 8 Jan 2015

@cryingDream94

This comment has been minimized.

Copy link
Author

@cryingDream94 cryingDream94 commented Aug 3, 2015

import OpenSSL
OpenSSL.SSL.OPENSSL_VERSION_NUMBER
9470383

@Kriechi

This comment has been minimized.

Copy link
Member

@Kriechi Kriechi commented Aug 3, 2015

mhm ok - this is the very old system OpenSSL

What about this?

import OpenSSL
OpenSSL.version.__version__
@cryingDream94

This comment has been minimized.

Copy link
Author

@cryingDream94 cryingDream94 commented Aug 3, 2015

import OpenSSL
OpenSSL.version.version
'0.13.1'

@Kriechi

This comment has been minimized.

Copy link
Member

@Kriechi Kriechi commented Aug 3, 2015

well, not sure why - but your python does not load the correct dependency...
The pyopenssl version must be 0.15.1 or higher (as stated in the setup.py of netlib).

@mhils any ideas?
didn't we have a openssl-version check somewhere in there to get a meaningful error message?

@cryingDream94

This comment has been minimized.

Copy link
Author

@cryingDream94 cryingDream94 commented Aug 3, 2015

wow , when I input sudo pip install --upgrade pyOpenSSL
➜ ~ sudo pip install --upgrade pyOpenSSL
Password:
The directory '/Users/mengxiangfeng/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/mengxiangfeng/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/vendor/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Requirement already up-to-date: pyOpenSSL in /Library/Python/2.7/site-packages
Requirement already up-to-date: six>=1.5.2 in /Library/Python/2.7/site-packages (from pyOpenSSL)
Collecting cryptography>=0.7 (from pyOpenSSL)
Downloading cryptography-0.9.3.tar.gz (303kB)
100% |████████████████████████████████| 303kB 466kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 20, in
File "/private/tmp/pip-build-3NfW2O/cryptography/setup.py", line 342, in
**keywords_with_side_effects(sys.argv)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 225, in init
_Distribution.init(self,attrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in init
self.finalize_options()
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 257, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2029, in require
working_set.resolve(self.dist.requires(self.extras),env,installer))
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 592, in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (certifi 2015.04.28 (/Library/Python/2.7/site-packages), Requirement.parse('certifi==1.0.1'))

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-3NfW2O/cryptography

@cryingDream94

This comment has been minimized.

Copy link
Author

@cryingDream94 cryingDream94 commented Aug 3, 2015

Now, when I input sudo pip install --upgrade pyOpenSSL in command, it shows 'RuntimeError: maximum recursion depth exceeded in cmp'
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2140, in from_location
basename, ext = os.path.splitext(basename)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 105, in splitext
return genericpath._splitext(p, sep, altsep, extsep)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.py", line 101, in _splitext
if p[filenameIndex] != extsep:
RuntimeError: maximum recursion depth exceeded in cmp

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-ml_rgU/cryptography

@mhils

This comment has been minimized.

Copy link
Member

@mhils mhils commented Aug 3, 2015

Yes. We accidentally built an import chain that imports netlib.tcp before the version check code is executed.

mhils added a commit to mitmproxy/netlib that referenced this issue Aug 3, 2015
mhils added a commit that referenced this issue Aug 3, 2015
@cryingDream94

This comment has been minimized.

Copy link
Author

@cryingDream94 cryingDream94 commented Aug 4, 2015

ok,thank you.But I'm not sure how to fix it.Uninstall OpenSSL and install it again? or pip uninstall pyOpenSSL and install it again?

I have try.OpenSSL can not be uninstall.when I uninstall pyOpenSSL and install it again, the problem still exist.I am very sad, because I do not know how to fix it.

@mhils

This comment has been minimized.

Copy link
Member

@mhils mhils commented Aug 4, 2015

Uninstall pyOpenSSL completely, reinstall pyOpenSSL using pip.

@cryingDream94

This comment has been minimized.

Copy link
Author

@cryingDream94 cryingDream94 commented Aug 4, 2015

➜ ~ pip uninstall pyOpenSSL
Cannot uninstall requirement pyOpenSSL, not installed

➜ ~ sudo pip install pyOpenSSL
The directory '/Users/mengxiangfeng/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/mengxiangfeng/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pyOpenSSL
/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/vendor/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading pyOpenSSL-0.15.1-py2.py3-none-any.whl (102kB)
100% |████████████████████████████████| 106kB 1.7MB/s
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /Library/Python/2.7/site-packages (from pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): cryptography>=0.7 in /Library/Python/2.7/site-packages (from pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): idna in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): enum34 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): cffi>=0.8 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /Library/Python/2.7/site-packages (from cffi>=0.8->cryptography>=0.7->pyOpenSSL)
Installing collected packages: pyOpenSSL
Successfully installed pyOpenSSL-0.15.1

Now successfully installed pyOpenSSL-0.15.1.When I input mitmproxy in commands,it shows:
➜ ~ mitmproxy
zsh: command not found: mitmproxy

Now I pip install mitmproxy, it shows:
➜ ~ sudo pip install mitmproxy
The directory '/Users/mengxiangfeng/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/mengxiangfeng/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting mitmproxy
/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/vendor/requests/packages/urllib3/util/ssl.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading mitmproxy-0.13.tar.gz (5.7MB)
100% |████████████████████████████████| 5.7MB 81kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 20, in
File "/private/tmp/pip-build-y5vydD/mitmproxy/setup.py", line 100, in
"beautifulsoup4"]})
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 225, in init
_Distribution.init(self,attrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in init
self.finalize_options()
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 257, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2029, in require
working_set.resolve(self.dist.requires(self.extras),env,installer))
.......
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 777, in scan
for dist in find_distributions(item):
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 1757, in find_on_path
path_item,entry,metadata,precedence=DEVELOP_DIST
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2151, in from_location
py_version=py_version, platform=platform, **kw
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2128, in init
self.project_name = safe_name(project_name or 'Unknown')
File "/Library/Python/2.7/site-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 1139, in safe_name
return re.sub('[^A-Za-z0-9.]+', '-', name)
RuntimeError: maximum recursion depth exceeded

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-y5vydD/mitmproxy

@cryingDream94

This comment has been minimized.

Copy link
Author

@cryingDream94 cryingDream94 commented Aug 4, 2015

Now successfully installed pyOpenSSL-0.15.1.When I input check OpenSSL version,it shows:

import OpenSSL
OpenSSL.version.version
'0.13.1'

@dellheng

This comment has been minimized.

Copy link

@dellheng dellheng commented Aug 4, 2015

+1

Python 2.7.6

ProductName: Mac OS X
ProductVersion: 10.10.4
BuildVersion: 14E46

➜  OpenSSL version
OpenSSL 0.9.8zf 19 Mar 2015
➜  sudo pip uninstall pyOpenSSL
Uninstalling pyOpenSSL-0.15.1:
  /Library/Python/2.7/site-packages/OpenSSL/SSL.py
  /Library/Python/2.7/site-packages/OpenSSL/SSL.pyc
  /Library/Python/2.7/site-packages/OpenSSL/__init__.py
  /Library/Python/2.7/site-packages/OpenSSL/__init__.pyc
  /Library/Python/2.7/site-packages/OpenSSL/_util.py
  /Library/Python/2.7/site-packages/OpenSSL/_util.pyc
  /Library/Python/2.7/site-packages/OpenSSL/crypto.py
  /Library/Python/2.7/site-packages/OpenSSL/crypto.pyc
  /Library/Python/2.7/site-packages/OpenSSL/rand.py
  /Library/Python/2.7/site-packages/OpenSSL/rand.pyc
  /Library/Python/2.7/site-packages/OpenSSL/test/__init__.py
  /Library/Python/2.7/site-packages/OpenSSL/test/__init__.pyc
  /Library/Python/2.7/site-packages/OpenSSL/test/test_crypto.py
  /Library/Python/2.7/site-packages/OpenSSL/test/test_crypto.pyc
  /Library/Python/2.7/site-packages/OpenSSL/test/test_rand.py
  /Library/Python/2.7/site-packages/OpenSSL/test/test_rand.pyc
  /Library/Python/2.7/site-packages/OpenSSL/test/test_ssl.py
  /Library/Python/2.7/site-packages/OpenSSL/test/test_ssl.pyc
  /Library/Python/2.7/site-packages/OpenSSL/test/test_tsafe.py
  /Library/Python/2.7/site-packages/OpenSSL/test/test_tsafe.pyc
  /Library/Python/2.7/site-packages/OpenSSL/test/test_util.py
  /Library/Python/2.7/site-packages/OpenSSL/test/test_util.pyc
  /Library/Python/2.7/site-packages/OpenSSL/test/util.py
  /Library/Python/2.7/site-packages/OpenSSL/test/util.pyc
  /Library/Python/2.7/site-packages/OpenSSL/tsafe.py
  /Library/Python/2.7/site-packages/OpenSSL/tsafe.pyc
  /Library/Python/2.7/site-packages/OpenSSL/version.py
  /Library/Python/2.7/site-packages/OpenSSL/version.pyc
  /Library/Python/2.7/site-packages/pyOpenSSL-0.15.1.dist-info/DESCRIPTION.rst
  /Library/Python/2.7/site-packages/pyOpenSSL-0.15.1.dist-info/METADATA
  /Library/Python/2.7/site-packages/pyOpenSSL-0.15.1.dist-info/RECORD
  /Library/Python/2.7/site-packages/pyOpenSSL-0.15.1.dist-info/WHEEL
  /Library/Python/2.7/site-packages/pyOpenSSL-0.15.1.dist-info/metadata.json
  /Library/Python/2.7/site-packages/pyOpenSSL-0.15.1.dist-info/top_level.txt
Proceed (y/n)? y
  Successfully uninstalled pyOpenSSL-0.15.1
➜  sudo pip install pyOpenSSL
Collecting pyOpenSSL
  Using cached pyOpenSSL-0.15.1-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /Library/Python/2.7/site-packages (from pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): cryptography>=0.7 in /Library/Python/2.7/site-packages (from pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): enum34 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): idna in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): cffi>=0.8 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /Library/Python/2.7/site-packages (from cffi>=0.8->cryptography>=0.7->pyOpenSSL)
Installing collected packages: pyOpenSSL
Successfully installed pyOpenSSL-0.15.1
➜  mitmproxy
Traceback (most recent call last):
  File "/usr/local/bin/mitmproxy", line 7, in <module>
    from libmproxy.main import mitmproxy
  File "/Library/Python/2.7/site-packages/libmproxy/main.py", line 7, in <module>
    from . import version, cmdline
  File "/Library/Python/2.7/site-packages/libmproxy/cmdline.py", line 5, in <module>
    from netlib import http
  File "/Library/Python/2.7/site-packages/netlib/http.py", line 7, in <module>
    from . import odict, utils, tcp, http_status
  File "/Library/Python/2.7/site-packages/netlib/tcp.py", line 26, in <module>
    'TLSv1.2': SSL.TLSv1_2_METHOD,
AttributeError: 'module' object has no attribute 'TLSv1_2_METHOD'
@dellheng

This comment has been minimized.

Copy link

@dellheng dellheng commented Aug 4, 2015

Python 2.7.6 (default, Sep  9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenSSL
>>> OpenSSL.version.__version__
'0.13.1'
>>>
@mhils

This comment has been minimized.

Copy link
Member

@mhils mhils commented Aug 4, 2015

You have an old version of pyOpenSSL installed somewhere (probably not via pip) - you need to remove that first.

python -c 'import os, inspect, OpenSSL; print os.path.dirname(inspect.getfile(OpenSSL))'
@dellheng

This comment has been minimized.

Copy link

@dellheng dellheng commented Aug 5, 2015

➜  ~  python -c 'import os, inspect, OpenSSL; print os.path.dirname(inspect.getfile(OpenSSL))'
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL
@karneaud

This comment has been minimized.

Copy link

@karneaud karneaud commented Aug 8, 2015

ever solved this problem?

I'm using python 2.7 and had installed pyOpenSSL successfully my path is

/Library/Python/2.7/site-packages/OpenSSL

which turns out to be version 0.15.1

@karneaud

This comment has been minimized.

Copy link

@karneaud karneaud commented Aug 8, 2015

still doesn't work/...

Not sure why thought i'm not seeing any "older" version of openssl and all my dependencies are intact..a permissions problem maybe?

@saalmaan

This comment has been minimized.

Copy link

@saalmaan saalmaan commented Aug 8, 2015

just found a simple solution to similar problem I had, I renamed the default openSSL folder

sudo mv /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_OpenSSL
@Kriechi

This comment has been minimized.

Copy link
Member

@Kriechi Kriechi commented Aug 9, 2015

Alternative solution 1:
Try installing python with homebrew: brew install python2
then use pip install mitmproxy (without sudo)

Alternative solution 2:
Try installing mitmproxy with homebrew: brew install mitmproxy

I'm also running on OSX - without issues, I'm using a venv with the homebrew python.

@Kriechi

This comment has been minimized.

Copy link
Member

@Kriechi Kriechi commented Aug 9, 2015

Alternative solution 3:
Use the provided OSX binary package from https://mitmproxy.org/

@karneaud

This comment has been minimized.

Copy link

@karneaud karneaud commented Aug 9, 2015

@saalmaan solution worked for me....wonder why though seeing my openssl was uptodate

@saalmaan

This comment has been minimized.

Copy link

@saalmaan saalmaan commented Aug 9, 2015

@Kriechi using binary does help with using mitmproxy, but sometimes like in case of Tamper you do need deflated - non binary installation of mitmproxy.

@karneaud here is the explanation from @mhils as to why openssl 0.14 doesnt get imported if you have default 0.13 installed (hence renaming default opensll folder does the trick)

We do have pyOpenSSL 0.14 listed as a requirement, which means it's getting installed when you install mitmproxy. What you're seeing is that you had 0.13 installed via non-pip methods, we installed 0.14 on setup, but 0.13 is still there and gets imported if we state import OpenSSL. This issue is quite common and we added the error message mentioned above. Nothing else we can do about it, sorry.

@dellheng

This comment has been minimized.

Copy link

@dellheng dellheng commented Aug 10, 2015

thank you @saalmaan renamed the default openSSL folder, have solved this problem

@cryingDream94

This comment has been minimized.

Copy link
Author

@cryingDream94 cryingDream94 commented Aug 13, 2015

I reinstall python, python 2.7.3 .Old version is 2.7.6. Then pip install mitmproxy.The problem has been resolved.

@karneaud

This comment has been minimized.

Copy link

@karneaud karneaud commented Aug 13, 2015

@saalmaan that maybe so but the requirement was for openssl to be >= 0.15. All system installs were > 0.15 and still didn't work.

@saalmaan

This comment has been minimized.

Copy link

@saalmaan saalmaan commented Aug 13, 2015

@karneaud Yes you may have the correct version of openssl installed but mitmproxy is not importing the it, you still have an older version laying around somewhere, until you don't get rid, that new version wont import properly. Or you can just replace old openssl with the new one, but be careful doing that might break default application in mac that rely on older version of openssl.

zbuc added a commit to zbuc/mitmproxy that referenced this issue Sep 1, 2015
@trufae

This comment has been minimized.

Copy link

@trufae trufae commented Sep 14, 2015

I fixed this issue with those commands:

$ cd /Library/Python/2.7/site-packages/
$ sudo mv pyOpenSSL*.dist-info /tmp/
$ sudo pip install pyOpenSSL

version was reporting 0.13

@Grazfather

This comment has been minimized.

Copy link

@Grazfather Grazfather commented Oct 12, 2015

I have the same issue. My import path indeed has 'Extras' before it has site-packages.

fwiw, you can run python -v to get a repl that dumps where it loads import from.

~ 13:09:26$ python -v
...
>>> import OpenSSL
import OpenSSL # directory /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL

I got around the issue by renaming it like @saalmaan did.

@atul2512

This comment has been minimized.

Copy link

@atul2512 atul2512 commented Oct 22, 2015

Hi, I followed the solution given here:http://stackoverflow.com/questions/32186174/making-mitm-proxy-run-on-mac

Basically I matched bot the version of openSSL (0.15.1), But still I am facing the same issue.Here is the sanpshot showing all information.
https://goo.gl/RyyCrC

@dgramop

This comment has been minimized.

Copy link

@dgramop dgramop commented Nov 5, 2015

All I did to make stop this error was uninstall mitmproxy from pip uninstall motmproxy from brew, install mitmproxy from brew

(using sudo -s [root shell])
#brew uninstall mitmproxy
#pip uninstall mitmproxy
#brew install mitmproxy

@preetb123

This comment has been minimized.

Copy link

@preetb123 preetb123 commented May 24, 2016

thanks @BrainyBrian

@teymur-mardaliyev

This comment has been minimized.

Copy link

@teymur-mardaliyev teymur-mardaliyev commented Nov 12, 2016

Hey there! I have updated my python versions (2.7.* and 3.5.*), deleted all mitmproxy and again I installed mitmproxy with pip (pip install mitmproxy) after all of this mitmproxy worked on my mac os x.
In addition, I was set up default python version to python3
I opened .bash_profile with sudo nano ~/.bash_profile
Wrote it to file alias python='python3'

@Kriechi

This comment has been minimized.

Copy link
Member

@Kriechi Kriechi commented Nov 13, 2016

Please use the mitmproxy-0.18.2-osx.tar.gz binaries from https://github.com/mitmproxy/mitmproxy/releases/tag/v0.18.2.
Those have an included python environment and contain a recent OpenSSL version that should fix your problem.

@Kriechi Kriechi reopened this Nov 13, 2016
@Kriechi Kriechi closed this Nov 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.