Running against non system ssl

Topic says it…my system openssl doesn’t support chacha-poly, so I’ve compiled and installed to /opt/openssl. How do I tell mitmproxy to use /opt/openssl? Thank you.

We use the cryptography library internally - if you update that, mitmproxy should pick up the changes right away. :slight_smile:

https://cryptography.io/en/latest/installation/#using-your-own-openssl-on-linux

Thank you. After following the instructions for Building Cryptography on Linux, Using Your Own OpenSSL on Linux, and Static Wheels, this is my result of sudo pip install mitmproxy:

Installing collected packages: mitmproxy, cryptography, urwid, hyperframe, hpack, blinker, backports.ssl-match-hostname, pyOpenSSL, six, html2text, lxml, construct, configargparse, pyperclip, certifi, Pillow, passlib, Flask, tornado, pyparsing, watchdog, requests, Werkzeug, Jinja2, itsdangerous, singledispatch, backports-abc, PyYAML, argh, pathtools, MarkupSafe
  Found existing installation: cryptography 1.5.2
    Uninstalling cryptography:
      Successfully uninstalled cryptography
  Running setup.py install for cryptography
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip_build_root/cryptography/setup.py", line 335, in <module>
        **keywords_with_side_effects(sys.argv)
      File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 318, in __init__
        _Distribution.__init__(self, attrs)
      File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
        self.finalize_options()
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 376, in finalize_options
        ep.load()(self, ep.name, value)
      File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 181, in cffi_modules
        add_cffi_module(dist, cffi_module)
      File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 48, in add_cffi_module
        execfile(build_file_name, mod_vars)
      File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 24, in execfile
        exec(code, glob, glob)
      File "src/_cffi_src/build_openssl.py", line 93, in <module>
        extra_link_args=extra_link_args(compiler_type()),
      File "/tmp/pip_build_root/cryptography/src/_cffi_src/utils.py", line 64, in build_ffi_for_binding
        extra_link_args=extra_link_args,
      File "/tmp/pip_build_root/cryptography/src/_cffi_src/utils.py", line 73, in build_ffi
        ffi.cdef(cdef_source)
      File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 105, in cdef
        self._cdef(csource, override=override, packed=packed)
      File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 119, in _cdef
        self._parser.parse(csource, override=override, **options)
      File "/usr/local/lib/python2.7/dist-packages/cffi/cparser.py", line 299, in parse
        self._internal_parse(csource)
      File "/usr/local/lib/python2.7/dist-packages/cffi/cparser.py", line 304, in _internal_parse
        ast, macros, csource = self._parse(csource)
      File "/usr/local/lib/python2.7/dist-packages/cffi/cparser.py", line 260, in _parse
        ast = _get_parser().parse(csource)
      File "/usr/local/lib/python2.7/dist-packages/cffi/cparser.py", line 40, in _get_parser
        _parser_cache = pycparser.CParser()
      File "/usr/local/lib/python2.7/dist-packages/pycparser/c_parser.py", line 87, in __init__
        outputdir=taboutputdir)
      File "/usr/local/lib/python2.7/dist-packages/pycparser/c_lexer.py", line 66, in build
        self.lexer = lex.lex(object=self, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/pycparser/ply/lex.py", line 911, in lex
        lexobj.readtab(lextab, ldict)
      File "/usr/local/lib/python2.7/dist-packages/pycparser/ply/lex.py", line 233, in readtab
        titem.append((re.compile(pat, lextab._lexreflags | re.VERBOSE), _names_to_funcs(func_name, fdict)))
      File "/usr/lib/python2.7/re.py", line 190, in compile
        return _compile(pattern, flags)
      File "/usr/lib/python2.7/re.py", line 242, in _compile
        p = sre_compile.compile(pattern, flags)
      File "/usr/lib/python2.7/sre_compile.py", line 509, in compile
        "sorry, but this version only supports 100 named groups"
    AssertionError: sorry, but this version only supports 100 named groups
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-m_dRSv-record/install-record.txt --single-version-externally-managed --compile:
    Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/tmp/pip_build_root/cryptography/setup.py", line 335, in <module>

    **keywords_with_side_effects(sys.argv)

  File "/usr/lib/python2.7/distutils/core.py", line 111, in setup

    _setup_distribution = dist = klass(attrs)

  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 318, in __init__

    _Distribution.__init__(self, attrs)

  File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__

    self.finalize_options()

  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 376, in finalize_options

    ep.load()(self, ep.name, value)

  File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 181, in cffi_modules

    add_cffi_module(dist, cffi_module)

  File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 48, in add_cffi_module

    execfile(build_file_name, mod_vars)

  File "/usr/local/lib/python2.7/dist-packages/cffi/setuptools_ext.py", line 24, in execfile

    exec(code, glob, glob)

  File "src/_cffi_src/build_openssl.py", line 93, in <module>

    extra_link_args=extra_link_args(compiler_type()),

  File "/tmp/pip_build_root/cryptography/src/_cffi_src/utils.py", line 64, in build_ffi_for_binding

    extra_link_args=extra_link_args,

  File "/tmp/pip_build_root/cryptography/src/_cffi_src/utils.py", line 73, in build_ffi

    ffi.cdef(cdef_source)

  File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 105, in cdef

    self._cdef(csource, override=override, packed=packed)

  File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 119, in _cdef

    self._parser.parse(csource, override=override, **options)

  File "/usr/local/lib/python2.7/dist-packages/cffi/cparser.py", line 299, in parse

    self._internal_parse(csource)

  File "/usr/local/lib/python2.7/dist-packages/cffi/cparser.py", line 304, in _internal_parse

    ast, macros, csource = self._parse(csource)

  File "/usr/local/lib/python2.7/dist-packages/cffi/cparser.py", line 260, in _parse

    ast = _get_parser().parse(csource)

  File "/usr/local/lib/python2.7/dist-packages/cffi/cparser.py", line 40, in _get_parser

    _parser_cache = pycparser.CParser()

  File "/usr/local/lib/python2.7/dist-packages/pycparser/c_parser.py", line 87, in __init__

    outputdir=taboutputdir)

  File "/usr/local/lib/python2.7/dist-packages/pycparser/c_lexer.py", line 66, in build

    self.lexer = lex.lex(object=self, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/pycparser/ply/lex.py", line 911, in lex

    lexobj.readtab(lextab, ldict)

  File "/usr/local/lib/python2.7/dist-packages/pycparser/ply/lex.py", line 233, in readtab

    titem.append((re.compile(pat, lextab._lexreflags | re.VERBOSE), _names_to_funcs(func_name, fdict)))

  File "/usr/lib/python2.7/re.py", line 190, in compile

    return _compile(pattern, flags)

  File "/usr/lib/python2.7/re.py", line 242, in _compile

    p = sre_compile.compile(pattern, flags)

  File "/usr/lib/python2.7/sre_compile.py", line 509, in compile

    "sorry, but this version only supports 100 named groups"

AssertionError: sorry, but this version only supports 100 named groups

----------------------------------------
  Rolling back uninstall of cryptography
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-m_dRSv-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/cryptography
Storing debug log for failure in /home/jlay/.pip/pip.log

it appears that mitmproxy uninstalled my cryptography. Thank you.