As part of a security test of an iOS app I'm developing, I'd like to verify that it correctly validates SSL/TLS certificates when connecting to various APIs. I installed mitmproxy on my Mac and [configured it as a transparent proxy](https://mitmproxy.org/doc/transparent/osx.html), then configured the WiFi based on this [transparent proxy iOS WiFi screenshot](https://mitmproxy.org/doc/screenshots/ios-gateway.png). The iPhone takes a very long time to show that it's connected to WiFi, and after it does, it can't access the network. Nothing at all shows up in mitmproxy, including in its event log:
![mitmproxy shows nothing](https://i.stack.imgur.com/F78p8.png)

Details of the mitmproxy configuration
--------------------------------------

I installed mitmproxy 0.11.3 in my system python (and renamed the outdated pyOpenSSL that ships with OSX, so that it uses pyOpenSSL 0.14 as installed with mitmproxy by pip).

I'm using the following script to configure and start pf and mitmproxy:

```
#!/bin/bash -x
sudo sysctl -w net.inet.ip.forwarding=1

# sudo sysctl -w net.inet.ip.scopedroute=0
## OSX can't change the net.inet.ip.scopedroute kernel flag in user space so I used:
## sudo defaults write "/Library/Preferences/SystemConfiguration/com.apple.Boot" "Kernel     Flags" "net.inet.ip.scopedroute=0
## and then rebooted
sudo defaults read /Library/Preferences/SystemConfiguration/com.apple.Boot

cat > pf.conf << _EOF_
rdr on en0 inet proto tcp to any port 80 -> 127.0.0.1 port 8080
rdr on en0 inet proto tcp to any port 443 -> 127.0.0.1 port 8080
_EOF_
cat pf.conf

sudo pfctl -d
sudo pfctl -f pf.conf
sudo pfctl -e

mitmproxy -T --host

```

Interface en0 is my Mac's WiFi connection.

The output from that script (visible after stopping mitmproxy with control-C) looks like this:

```
$ ./transparent.sh 
+ sudo sysctl -w net.inet.ip.forwarding=1
net.inet.ip.forwarding: 1 -> 1
+ sudo defaults read /Library/Preferences/SystemConfiguration/com.apple.Boot
{
    "Kernel Flags" = "net.inet.ip.scopedroute=0";
}
+ cat
+ cat pf.conf
rdr on en0 inet proto tcp to any port 80 -> 127.0.0.1 port 8080
rdr on en0 inet proto tcp to any port 443 -> 127.0.0.1 port 8080
+ sudo pfctl -d
No ALTQ support in kernel
ALTQ related functions disabled
pf disabled
+ sudo pfctl -f pf.conf
pfctl: Use of -f option, could result in flushing of rules
present in the main ruleset added by the system at startup.
See /etc/pf.conf for further details.

No ALTQ support in kernel
ALTQ related functions disabled
+ sudo pfctl -e
No ALTQ support in kernel
ALTQ related functions disabled
pf enabled
+ mitmproxy -T --host

```

Details of the iOS configuration
--------------------------------

I'm using a physical iPhone5s on iOS 8.1 and connecting to the same WiFi network as the Mac. My WiFi configuration looks like this:
![transparent proxy wifi config on iPhone](https://i.stack.imgur.com/f0PWO.png)

I've used 192.168.20.118 because that is the IP address of my Mac on the same WiFi network, which I found using ifconfig:

```
$ ifconfig
[...]
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether xx:xx:xx:xx:xx:xx 
    inet6 fe80::22c9:d0ff:fe84:983b%en0 prefixlen 64 scopeid 0x4 
    inet 192.168.20.118 netmask 0xffffff00 broadcast 192.168.20.255
    nd6 options=1<PERFORMNUD>
    media: autoselect
    status: active
[...]

```