无法通过 iPhone
模拟器访问服务器,但能够通过浏览器访问相同的 API(在网络设置中启用代理)。
没有受信任的证书。
错误日志
nw_proxy_resolver_create_parsed_array PAC evaluation error: NSURLErrorDomain: -1003 NSURLSession/NSURLConnection HTTP load failed The certificate for this server is invalid. You might be connecting to a server that is pretending to be "domain name"...
TIC SSL 信任错误
最佳答案
尝试在 Appdelegate 类末尾添加 @end 之后,
Objective-C
@implementation NSURLRequest(ATS)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host {
return YES;
}
@end
swift
extension URLRequest {
static func allowsAnyHTTPSCertificate(forHost host: String?) -> Bool {
return true
}
}
关于ios - 无法从服务器获取响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56443574/