Installing mitmproxy CA certificate

Hello.
I have a rare condition that only reproduces on CI sometimes. It’s network related, so I thought I’d install a proxy. Problem is I can’t install the proxy certificate and thus the build fails (or in my case get stuck in an endless loop of retries, but that’s solvable)

This is the script I run to install and run the proxy (I chose mitmproxy and want to use mitmdump):

#!/usr/bin/env bash
sudo apt-get install mitmproxy
sudo mkdir /usr/share/ca-certificates/extra
sudo cp ~/.mitmproxy/mitmproxy-ca-cert.cer /usr/share/ca-certificates/extra
sudo echo "extra/mitmproxy-ca-cert.cer" >> /etc/ca-certificates.conf
sudo update-ca-certificates
mitmdump -s ./har_dump.py --set hardump=./network.log.har &

and these are the lines I see when it runs:

cp: cannot stat '/home/travis/.mitmproxy/mitmproxy-ca-cert.cer': No such file or directory
./setup_proxy.sh: line 5: /etc/ca-certificates.conf: Permission denied

Is installing new certificates even possible on Travis-CI? Is there a built-in proxy or certificate I can use? Also, where is mitmproxy installed if not at /home/travis/.mitmproxy? Where are things get installed?

1 Like

It took some digging in but this was indeed the solution.

Thanks!

Imprint