Objective c 发生SSL错误
我在iTunes上上传了我的应用程序,它也是实时的,但在一些设备上(主要是iPhone7)。将Xcode或ios版本升级到11.4后,我遇到了SSL连接错误。Objective c 发生SSL错误,objective-c,iphone,ios11,Objective C,Iphone,Ios11,我在iTunes上上传了我的应用程序,它也是实时的,但在一些设备上(主要是iPhone7)。将Xcode或ios版本升级到11.4后,我遇到了SSL连接错误。 在iphone6s或ipad上工作正常,但在客户端iphone7上发生此错误,并附上了错误的屏幕截图,我无法理解发生了什么,需要更改什么 我已经在info plist中添加了此代码 <key>NSAppTransportSecurity</key> <dict> <key&
在iphone6s或ipad上工作正常,但在客户端iphone7上发生此错误,并附上了错误的屏幕截图,我无法理解发生了什么,需要更改什么 我已经在info plist中添加了此代码
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>yourdomain.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
NSAppTransportSecurity
NSAllowsArbitraryLoads
NSExceptionDomains
yourdomain.com
n包括多个域
N第三方例外要求转发保密
我们还检查服务器证书,它们也是有效的
首先检查您的端口是否有SSL以及用于SSL固定的正确证书 检查SSL的代码
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
if ([trustedHosts containsObject:challenge.protectionSpace.host])
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}