我对客户端证书认证并没有太多经验。有人可以告诉我如何在iOS应用程序中使用它吗?谢谢:)
我对客户端证书认证并没有太多经验。有人可以告诉我如何在iOS应用程序中使用它吗?谢谢:)
你的 NSURLConnection 代理应该响应 connection:didReceiveAuthenticationChallenge:
代理方法(见下面的链接)。
它应该通过询问挑战的“sender”并为其提供适当的凭据来进行响应。
例如:
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
id sender = [challenge sender];
// create a credential from a certificate
// see doco for details of the parameters
NSURLCredential *creds = [NSURLCredential credentialWithIdentity:ident certificates:certs persistence:persistence];
[sender useCredential:creds forAuthenticationChallenge:challenge];
}
查看NSURLCredential类参考资料,了解如何基于证书创建凭据的详细信息: