1 mitmCacheConfigureHook
() {
2 if [ -d "$mitmCache" ] && [ -z "$MITM_CACHE_CERT_DIR" ]; then
3 MITM_CACHE_CERT_DIR
="$(mktemp -d)"
4 pushd "$MITM_CACHE_CERT_DIR"
5 MITM_CACHE_CA
="$MITM_CACHE_CERT_DIR/ca.cer"
6 @openssl@
/bin
/openssl genrsa
-out ca.key
2048
7 @openssl@
/bin
/openssl req
-x509 -new -nodes -key ca.key
-sha256 -days 1 -out ca.cer
-subj "/C=AL/ST=a/L=a/O=a/OU=a/CN=example.org"
8 MITM_CACHE_HOST
="127.0.0.1"
9 MITM_CACHE_PORT
="${mitmCachePort:-$(@ephemeral_port_reserve@/bin/ephemeral-port-reserve "$MITM_CACHE_HOST")}"
10 MITM_CACHE_ADDRESS
="$MITM_CACHE_HOST:$MITM_CACHE_PORT"
11 export http_proxy
="$MITM_CACHE_ADDRESS"
12 export https_proxy
="$MITM_CACHE_ADDRESS"
13 export SSL_CERT_FILE
="$MITM_CACHE_CA"
14 export NIX_SSL_CERT_FILE
="$MITM_CACHE_CA"
15 mitm-cache
-l"$MITM_CACHE_ADDRESS" replay
"$mitmCache" >/dev
/null
2>/dev
/null
&
20 # prepend it so any other configure hooks can use the generated root CA
21 preConfigureHooks
=(mitmCacheConfigureHook
"${preConfigureHooks[@]}")