App Transport Security policy requires the use of a secure connection - IOS 9

后端 未结 2 1306
野性不改
野性不改 2020-12-29 00:07

I\'m facing problem connection to API with using IP address. Even I had add the following code to plist, it still show error as below:

\"http://xx3.xx.xx8.xx7/xxx/x

2条回答
  •  萌比男神i
    2020-12-29 00:26

    Document Allowing Insecure Connection to a Single Server here. So you must add NSAppTransportSecurity to your info.plist file in truth way like flowing (to show Info.plist in source, in Xcode right click to Info.plist "Open As"->"Source Code")

    To configure a per-domain exception:

    
    
    
    
        
        NSAppTransportSecurity
        
            NSExceptionDomains
            
                insecure-domain1.example.com
                
                    NSIncludesSubdomains
                    
                    NSExceptionAllowsInsecureHTTPLoads
                    
                    NSExceptionRequiresForwardSecrecy
                    
                    NSExceptionMinimumTLSVersion
                    TLSv1.0
                
                insecure-domain2.example.com
                
                    NSIncludesSubdomains
                    
                    NSExceptionAllowsInsecureHTTPLoads
                    
                    NSExceptionRequiresForwardSecrecy
                    
                    NSExceptionMinimumTLSVersion
                    TLSv1.0
                
            
        
        
    
    
    

    after edit Infor.plist file look like following:

    Or disable ATS:

    
    
    
    
        ...
        NSAppTransportSecurity
        
            
            NSAllowsArbitraryLoads
            
        
    
    
    

    after edit Infor.plist file look like following:

提交回复
热议问题