2

I am using an NSURLSession to make a simple HTTPS GET request like so with a HTTPS proxy:

NSURL *url = [NSURL URLWithString:@"https://www.mysecureurl.com"];

NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
NSDictionary *proxyDictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"127.0.0.1", @"kCFProxyHostNameKey", @1234, @"kCFProxyPortNumberKey", @"kCFProxyTypeHTTPS", @"kCFProxyTypeKey", nil];
config.connectionProxyDictionary = proxyDictionary;

NSURLSession *session = [NSURLSession sessionWithConfiguration:config];
NSURLSessionDataTask *dataTask = [session dataTaskWithURL:url completionHandler: ^ (NSData *data, NSURLResponse *response, NSError *error) {
    if (!error) {
        NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); //The URL returns the requesters IP address, thus the NSLog should be the IP of the proxy.
    } else {
        NSLog(@"%@", error.description);
    }
}];
[dataTask resume];

However when I run this code, no error is logged, but my actual IP address is logged when I am expecting to see the proxy's IP address logged. Effectively the NSURLSession isn't using the proxy but still makes the request using my IP address. Why this is I cannot work out and would appreciate any sort of direction.

Josh

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Josh
  • 254
  • 3
  • 19

0 Answers0