Here is my situation, I need to connect through a tor proxy to a .onion address on the Tor network. I'm using Tor.framework in my app and I can connect to Tor fine. Tor framework spins up a proxy that runs inside the app and I set my proxy configuration with URLSession and all is great.
However On a physical device, when I attempt to load a URL at a .onion address, I get an error -1009, "The Internet connection appears to be offline."
NOTE:
- this error only happens when loading .onion address from a hardware device
- I am able to load a .onion address from the SIMULATOR with no problems
- On the physical device, I am able to send requests through the proxy to a non-onion address and I can confirm that I have a TOR IP address.
- I have enabled allow arbitrary Loads in my ATS
My thoughts are that something at the URLSession level doesn't like the .onion domain for some reason or there is some other device specific security setting I am not aware of.
To prove this is not a TOR specific error I have done the following:
- remove the code to connect to tor and the proxy setup step and send a request to a .onion address with the default url session and config
- I get the same "internet connection appears to be offline" error on the physical device
- I get a the expected error on the simulator "A server with the specified hostname could not be found."
Thanks for your help
let sessionConfiguration = URLSessionConfiguration.default sessionConfiguration.connectionProxyDictionary = [ kCFProxyHostNameKey as AnyHashable: "127.0.0.1", kCFProxyPortNumberKey as AnyHashable: 39050, //myPortInt kCFProxyTypeKey as AnyHashable: kCFProxyTypeSOCKS ] self.newSession = URLSession(configuration: config) // THIS FIND MY URL REQUEST WORKS FINE AND GIVES ME A NEW REMOTE IP //let url = "http://api.ipify.org?format=json" //.onion address let url = "http://3heens4xbedlj57xwcggjsdglot7e36p4rogy642xokemfo2duh6bbyd.onion/" let request = URLRequest(url: URL(string:url)!, cachePolicy: URLRequest.CachePolicy.reloadIgnoringLocalCacheData, timeoutInterval: 10) self.newSession.dataTask(with: request, completionHandler: { (responseData, urlResponse, error) -> Void in // THE .onion address request works fine on the simulator. // BUT gives a -1009 error on physical device. })