NSAllowsArbitraryLoads not working for ip address

I am trying to connect my application to an HTTP server at 152.111.198.244 through Apple Transport Security. And I’m not trying to work.

Adding the NSAllowsArbitraryLoads key to my project's info.plist file still prevents my application from connecting to this specific IP address 152.111.198.244 I went through technote in Apple Transport Security. I installed OSX 10.11 to try and find which settings might work for the url using

nscurl --ats-diagnostics http://152.111.198.244 

and

 nscurl --ats-diagnostics http://152.111.198.244/publications/ 

in the terminal. All settings that nscurl is trying to do. I examined similar issues NSAllowsArbitraryLoads does not work and NSExceptionAllowsInsecureHTTPLoads does not work for IP addresses and did not find a solution, I also looked here and the NSExceptionMinimumTLSVersion key suggested there does not work.

I'm starting to think that somewhere there might be a mistake, or something that I missed. Are there problems with the IP addresses of Apple Transport Security? What for? Is there a way to make the IP address work through ATS?

UPDATE: I added to a specific IP address which is causing me problems. Hope someone can reproduce what I'm talking about.

UPDATE: I recorded this as a bug in the radar, and I got a message saying it was a duplicate. Meanwhile, the IP address mentioned in this question now has the domain name http://3d.media24.com/ , but unfortunately it did not solve the problem.

UPDATE: I answered the answer correctly. It looks like Apple fixed this with Xcode7.1 and that the keys for Apple Transport Security have changed a bit. This site has also been updated for https connections.

+5
source share
2 answers

I was able to access this URL, http://152.111.198.244 , using the "Allow arbitrary downloads in my Info.plist in Xcode 7.1 and Simulator 9.1:

  • Security Settings for Application Transport: Dictionary
    • Allow arbitrary loads: Boolean = YES

Screenshot:

enter image description here

I used the following code:

 let url = NSURL(string: "http://152.111.198.244")! let task = NSURLSession.sharedSession().dataTaskWithURL(url) {(data, response, error) -> Void in print("response \(response!)") } task.resume() 

Here is the answer I received:

 response <NSHTTPURLResponse: 0x7fe1a2421f80> { URL: http://152.111.198.244/auth/login } { status code: 200, headers { "Cache-Control" = "no-cache"; Connection = "Keep-Alive"; "Content-Encoding" = gzip; "Content-Length" = 1138; "Content-Type" = "text/html; charset=UTF-8"; Date = "Fri, 23 Oct 2015 09:33:59 GMT"; "Keep-Alive" = "timeout=5, max=98"; Server = "Apache/2.4.7 (Ubuntu)"; "Set-Cookie" = "XSRF-TOKEN=eyJpdiI6IldBOWYxcDk3SEtMekJ3YTNSUm9mYUE9PSIsInZhbHVlIjoiTFBcL3RGWW10cjlONFFkeXY1ZDA4SWRkSURIYlFsOGE3QkFEV3hRNTVwRFJuWSt5SXN3OU55Sng4elduMHd1T1duV0VFQ1o4dDVjeDJTZGRFeXJxMjN3PT0iLCJtYWMiOiJiZjNmOTg0NTZmY2RkMGQzNmE2YWEyNjJiNzA1MDlmZjIwM2M3NWYyNjYwZjM5N2Q3ZTgxNjRjNzAzMGYzYmMzIn0%3D; expires=Fri, 23-Oct-2015 11:33:59 GMT; Max-Age=7200; path=/, laravel_session=eyJpdiI6InR5OSs3cmpObVRBbFhORnVJQjRvWFE9PSIsInZhbHVlIjoiSTJ2bk41RVVLZUR1a0xKbFwvalZXQWpsNEtWeHppUVpYVUlRM1ZjQXc5aDJxT1wvXC9uYkViaTQ0SCtGNTMrdmtiQXFOd0VJTFwvM0ZCbmFHZk5MWlwvZ3BBUT09IiwibWFjIjoiYjRmNzcxY2Q5NDFlZjYzZTI1YzU2YzI0YTkxM2M0NDg0MGY2YThiODIxOGZjOTgxYjNmM2FlZTkzZGMyZTdjOCJ9; expires=Fri, 23-Oct-2015 11:33:59 GMT; Max-Age=7200; path=/; httponly"; Vary = "Accept-Encoding"; "X-Powered-By" = "PHP/5.5.9-1ubuntu4.11"; } } -TOKEN = eyJpdiI6IldBOWYxcDk3SEtMekJ3YTNSUm9mYUE9PSIsInZhbHVlIjoiTFBcL3RGWW10cjlONFFkeXY1ZDA4SWRkSURIYlFsOGE3QkFEV3hRNTVwRFJuWSt5SXN3OU55Sng4elduMHd1T1duV0VFQ1o4dDVjeDJTZGRFeXJxMjN3PT0iLCJtYWMiOiJiZjNmOTg0NTZmY2RkMGQzNmE2YWEyNjJiNzA1MDlmZjIwM2M3NWYyNjYwZjM5N2Q3ZTgxNjRjNzAzMGYzYmMzIn0% 3D; expires = Fri, response <NSHTTPURLResponse: 0x7fe1a2421f80> { URL: http://152.111.198.244/auth/login } { status code: 200, headers { "Cache-Control" = "no-cache"; Connection = "Keep-Alive"; "Content-Encoding" = gzip; "Content-Length" = 1138; "Content-Type" = "text/html; charset=UTF-8"; Date = "Fri, 23 Oct 2015 09:33:59 GMT"; "Keep-Alive" = "timeout=5, max=98"; Server = "Apache/2.4.7 (Ubuntu)"; "Set-Cookie" = "XSRF-TOKEN=eyJpdiI6IldBOWYxcDk3SEtMekJ3YTNSUm9mYUE9PSIsInZhbHVlIjoiTFBcL3RGWW10cjlONFFkeXY1ZDA4SWRkSURIYlFsOGE3QkFEV3hRNTVwRFJuWSt5SXN3OU55Sng4elduMHd1T1duV0VFQ1o4dDVjeDJTZGRFeXJxMjN3PT0iLCJtYWMiOiJiZjNmOTg0NTZmY2RkMGQzNmE2YWEyNjJiNzA1MDlmZjIwM2M3NWYyNjYwZjM5N2Q3ZTgxNjRjNzAzMGYzYmMzIn0%3D; expires=Fri, 23-Oct-2015 11:33:59 GMT; Max-Age=7200; path=/, laravel_session=eyJpdiI6InR5OSs3cmpObVRBbFhORnVJQjRvWFE9PSIsInZhbHVlIjoiSTJ2bk41RVVLZUR1a0xKbFwvalZXQWpsNEtWeHppUVpYVUlRM1ZjQXc5aDJxT1wvXC9uYkViaTQ0SCtGNTMrdmtiQXFOd0VJTFwvM0ZCbmFHZk5MWlwvZ3BBUT09IiwibWFjIjoiYjRmNzcxY2Q5NDFlZjYzZTI1YzU2YzI0YTkxM2M0NDg0MGY2YThiODIxOGZjOTgxYjNmM2FlZTkzZGMyZTdjOCJ9; expires=Fri, 23-Oct-2015 11:33:59 GMT; Max-Age=7200; path=/; httponly"; Vary = "Accept-Encoding"; "X-Powered-By" = "PHP/5.5.9-1ubuntu4.11"; } } ; expires = Fri, response <NSHTTPURLResponse: 0x7fe1a2421f80> { URL: http://152.111.198.244/auth/login } { status code: 200, headers { "Cache-Control" = "no-cache"; Connection = "Keep-Alive"; "Content-Encoding" = gzip; "Content-Length" = 1138; "Content-Type" = "text/html; charset=UTF-8"; Date = "Fri, 23 Oct 2015 09:33:59 GMT"; "Keep-Alive" = "timeout=5, max=98"; Server = "Apache/2.4.7 (Ubuntu)"; "Set-Cookie" = "XSRF-TOKEN=eyJpdiI6IldBOWYxcDk3SEtMekJ3YTNSUm9mYUE9PSIsInZhbHVlIjoiTFBcL3RGWW10cjlONFFkeXY1ZDA4SWRkSURIYlFsOGE3QkFEV3hRNTVwRFJuWSt5SXN3OU55Sng4elduMHd1T1duV0VFQ1o4dDVjeDJTZGRFeXJxMjN3PT0iLCJtYWMiOiJiZjNmOTg0NTZmY2RkMGQzNmE2YWEyNjJiNzA1MDlmZjIwM2M3NWYyNjYwZjM5N2Q3ZTgxNjRjNzAzMGYzYmMzIn0%3D; expires=Fri, 23-Oct-2015 11:33:59 GMT; Max-Age=7200; path=/, laravel_session=eyJpdiI6InR5OSs3cmpObVRBbFhORnVJQjRvWFE9PSIsInZhbHVlIjoiSTJ2bk41RVVLZUR1a0xKbFwvalZXQWpsNEtWeHppUVpYVUlRM1ZjQXc5aDJxT1wvXC9uYkViaTQ0SCtGNTMrdmtiQXFOd0VJTFwvM0ZCbmFHZk5MWlwvZ3BBUT09IiwibWFjIjoiYjRmNzcxY2Q5NDFlZjYzZTI1YzU2YzI0YTkxM2M0NDg0MGY2YThiODIxOGZjOTgxYjNmM2FlZTkzZGMyZTdjOCJ9; expires=Fri, 23-Oct-2015 11:33:59 GMT; Max-Age=7200; path=/; httponly"; Vary = "Accept-Encoding"; "X-Powered-By" = "PHP/5.5.9-1ubuntu4.11"; } } 

I was also able to connect using the named domain 3d.media24.com , but not with the numeric address 152.111.198.244 using the exception domains.

Screenshot:

enter image description here

My results are consistent with the Apple Technote application security domain definition of exclusion domains:

An exception dictionary for a named domain. The key name is the domain name, for example, www.apple.com.

+1
source

Some useful fields can be added below Security settings of the application for transport:

 NSIncludesSubdomains NSExceptionAllowInsecureHTTPLoads NSExceptionRequiresForwardSecrecy NSExceptionMinimumTLSVersion NSThirdPartyExceptionAllowsInsecureHTTPLoads NSThirdPartyExceptionMinimumTLSVersion NSThirdPartyExceptionRequiresForwardSecrecy 

Visit https://github.com/ChenYilong/iOS9AdaptationTips#1-demo1_ios9%E7%BD%91%E7%BB%9C%E9%80%82%E9%85%8D_ats%E6%94%B9%E7%94 % A8% E6% 9B% B4% E5% AE% 89% E5% 85% A8% E7% 9A% 84https for wider use.

Hope to help!

0
source

Source: https://habr.com/ru/post/1233327/


All Articles