The "Proxy Authentication Required" dialog on iOS occurs when an app or the system is unable to authenticate with a proxy server. This can happen even after passing the username and password via NEProxyServer. Here are a few key points:
- Setting the proxy credentials programmatically in NEProxyServer's properties (username, password) does not always work. The dialog still appears asking the user to manually enter the credentials[1][2].
- Enabling basic authentication on the proxy server (e.g. with mitmproxy using --proxyauth) works for HTTP but not always for HTTPS on iOS. This seems to be a protocol-level bug in mitmproxy that was introduced in version 8.1.0[4].
- On macOS, the issue can occur when system processes try to access internet resources before the Mac has a chance to pull a Kerberos ticket from the proxy. Allowing these processes to use a non-authenticated proxy can help resolve the prompts[5].
- Debugging the app's code and checking for any unintended redirects in the server configuration files are other troubleshooting steps that may help[3].
In summary, the "Proxy Authentication Required" dialog on iOS is a known issue when using proxies. Programmatically setting the credentials doesn't always work, and there may be protocol-level bugs in some proxy servers. Consulting with the proxy team to whitelist certain destinations is recommended.
Citations:[1] https://forums.developer.apple.com/thread/112201
[2] https://stackoverflow.com/questions/53852899/ios-keep-showing-proxy-authentication-required-dialog-even-after-passing-usern
[3] https://kinsta.com/knowledgebase/http-error-407/
[4] https://github.com/mitmproxy/mitmproxy/issues/6420
[5] https://community.jamf.com/t5/jamf-pro/the-ever-present-quot-proxy-authentication-required-quot-prompt/m-p/172881