HTTP load failed (kCFStreamErrorDomainSSL, -9806 ( IOS9)

后端 未结 1 1738
一整个雨季
一整个雨季 2020-12-22 03:10

I am getting the NSURLSession/NSURLConnection HTTP load failed on iOS 9 while running app on Simulator. Here is how my info.plist file looks like

         


        
1条回答
  •  囚心锁ツ
    2020-12-22 03:40

    You need to define the URL you want to apply these rules for. You can find the correct declaration on Apple's documentation page: https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/

    So basically your Info.plist should look like this and include the domain.

    Note: for better transparency, I also redeclared the default value for NSAllowsArbitraryLoads to be false

    NSAppTransportSecurity
    
        NSAllowsArbitraryLoads
        
        NSExceptionDomains
        
            yourdomain.com
            
                NSIncludesSubdomains
                
                NSAllowsArbitraryLoads
                
                NSTemporaryExceptionMinimumTLSVersion
                TLSv1.1
                NSTemporaryExceptionAllowsInsecureHTTPLoads
                
            
        
    
    

    Best regards.

    In case, you just don't care about all these ssl mess ups (I do not recommend this) and want to only go for debugging your UI, you can alternatively go temporarily and use the non-default for App TransportSecurity and allow just anything:

    NSAppTransportSecurity
    
        NSAllowsArbitraryLoads
        
    
    

    I am not sure, whether Apple would let this pass in the AppStore Review ;-)

    0 讨论(0)
提交回复
热议问题