我需要与服务器通信,我需要为每个 NSURLRequest
附加一个自签名的 TLS 证书。
有办法吗?
最佳答案
您的连接委托(delegate)应实现 connection:canAuthenticateAgainstProtectionSpace:
并回答 YES。完成后,您的代表将收到 connection:didReceiveAuthenticationChallenge:
要继续处理证书,该方法应回答 NSURLCredential。使用您的证书创建其中一个
+ (NSURLCredential *)credentialWithIdentity:(SecIdentityRef)identity certificates:(NSArray *)certArray persistence:(NSURLCredentialPersistence)persistence
关于ios - 如何在 NSURLRequest 中附加 TLS/SSL 证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15115311/