[Solved] Mitmproxy in separated python thread

Hi there, I have a few questions after updating to 4.0.1.

  1. How it possible to run mitmproxy from separated thread?

Now I’m trying this way:

from mitmproxy import proxy, options
from mitmproxy.master import Master
from mitmproxy.proxy import ProxyServer

opts = options.Options(listen_port=port)
config = proxy.ProxyConfig(opts)
server = ProxyServer(config)
proxy_master = ProxyMaster(opts)
proxy_master.server = server

def run():

thread = Thread(target=run)
thread.daemon = True

but nothing happens (I know that this code will be exited after executing in thread, but I have a lot of stuff down there)… if I start it through proxy_master.run() in main thread (without threading) - all will work as expected.

  1. How can I specify cert that will be installed in system, on previous version you have cadir option but now it gone.

Found solution, changed from:




Hope this will be helpful to somebody.

Okay now I found that confdir option works like cadir in previous versions so we can use it to specify another ca cert. But if this cert is installed we getting lot of errors, in this case you should disable http2 in options.

:smiley: Can be closed