Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon What are the best practices for setting up proxy credentials in an iOS VPN app


What are the best practices for setting up proxy credentials in an iOS VPN app


To set up proxy credentials effectively in an iOS VPN app, consider the following best practices:

1. Use NEProxyServer Configuration

- Programmatic Setup: Utilize the `NEProxyServer` class to configure the proxy settings programmatically. Set the server address, port, and authentication details as shown below:

objc
  self.vpnManager.protocolConfiguration.proxySettings.HTTPSServer = [[NEProxyServer alloc] initWithAddress:proxyServer port:proxyPort];
  self.vpnManager.protocolConfiguration.proxySettings.HTTPSServer.authenticationRequired = YES;
  self.vpnManager.protocolConfiguration.proxySettings.HTTPSServer.username = proxyUser;
  self.vpnManager.protocolConfiguration.proxySettings.HTTPSServer.password = proxyPassword;
  

- Save Preferences: Ensure that you save the configuration preferences after setting the proxy details to persist the information across app launches.

2. Handle Authentication Gracefully

- Automatic Updates: If your proxy credentials change frequently, implement a background task to update the credentials automatically without user intervention. This can be similar to the delegate method used in `NSURLSession` for handling authentication challenges.

- Error Handling: Be prepared to handle cases where the credentials may not be accepted, leading to the "Proxy Authentication Required" dialog. Logging the credentials can help debug issues, but ensure sensitive information is handled securely.

3. Use Certificate-Based Authentication

- Secure Authentication: Where possible, use certificate-based authentication instead of username/password pairs. This method enhances security and can streamline the authentication process since it doesn't require user interaction.

4. Optimize Proxy Settings

- Choose the Right Proxy: Ensure that the proxy server you are using supports the required protocols (HTTP/HTTPS) and is optimized for mobile data. This includes selecting a proxy that can handle the expected traffic load without significant latency.

- Whitelisting: If certain applications do not function correctly through the proxy, consider whitelisting them to bypass the proxy settings, allowing them to connect directly to the internet.

5. Test and Validate

- Connection Testing: After configuring the proxy, perform thorough testing to ensure that the VPN app connects successfully through the proxy without prompting for credentials. Use tools to monitor network traffic and validate that requests are routed correctly.

- User Feedback: If users experience issues, provide a way for them to report problems easily, which can help in troubleshooting and improving the app's functionality.

By following these best practices, you can effectively manage proxy credentials in an iOS VPN app, enhancing both security and user experience while minimizing the need for manual intervention.

Citations:
[1] https://stackoverflow.com/questions/53852899/ios-keep-showing-proxy-authentication-required-dialog-even-after-passing-usern
[2] https://docs.paloaltonetworks.com/globalprotect/10-1/globalprotect-admin/mobile-endpoint-management/manage-the-globalprotect-app-using-workspace-one/configure-workspace-one-for-ios-endpoints/configure-a-per-app-vpn-configuration-for-ios-endpoints-using-workspace-one
[3] https://netnut.io/how-to-set-proxy-on-mobile-data-ios/
[4] https://www.hexnode.com/mobile-device-management/help/how-to-configure-per-app-vpn-in-ios-devices-using-hexnode-mdm/
[5] https://smartproxy.com/configuration/how-to-setup-proxy-for-iphone