我有一个iPhone应用程序,需要与我的Web服务建立安全连接
我有一个创建的CA,想要添加到应用程序中,以便它创建连接并验证我的服务器
我正在使用restkit 0.20.3发出请求。
如何配置AFHHTTPClient信任我的证书?
最佳答案
仅将您的URL添加为https://
formate即可,因为您的信息将根据SSL证书进行加密
在ASIHttpRequest客户端证书支持中
如果您的服务器要求使用客户端证书,从v1.8开始,现在可以将其与您的请求一起发送。
// Will send the certificate attached to the identity (identity is a SecIdentityRef)
[request setClientCertificateIdentity:identity];
// Add an additional certificate (where cert is a SecCertificateRef)
[request setClientCertificates:[NSArray arrayWithObject:(id)cert]];
iPhone / iPad示例应用程序的ClientCertificateTests.m中有一个辅助函数,可以从PKCS12数据创建SecIdentityRef(此函数仅在iOS上有效)。
并在此处查看有关在iOS端处理自签名证书的更多信息:
Use a self-signed ssl certificate in an iphone app
iPhone: install certificate for SSL connection
关于ios - 如何设置应用程序以仅信任一个SSL证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21425491/