Use specific host IP for NSURLSession

I would like to use NSURLSession to fetch a given URL (using HTTPS), but I would like to specify the IP address that should be used for that connection.

Similarly to what this does:
Code Block
curl https://www.google.com --resolve 172.217.16.46

How can I do that?
Answered by Systems Engineer in 642004022
I suspect you are seeing a peer trust failure from NSURLSession when SecTrustRef is evaluated on the server side. This is because the TLS certificate cannot be verified on the server side based on the details found in the certificate, like Subject Name etc... If you really needed to do this you could setup your own trust evaluation and make these decisions on your own for you application, i.e., let the connection proceed or fail, but it's best to connect by name here.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Accepted Answer
I suspect you are seeing a peer trust failure from NSURLSession when SecTrustRef is evaluated on the server side. This is because the TLS certificate cannot be verified on the server side based on the details found in the certificate, like Subject Name etc... If you really needed to do this you could setup your own trust evaluation and make these decisions on your own for you application, i.e., let the connection proceed or fail, but it's best to connect by name here.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Use specific host IP for NSURLSession
 
 
Q