【发布时间】:2013-02-23 11:21:47
【问题描述】:
我有这个设置:
- 配置为使用 ssl 客户端证书身份验证的 tomcat 服务器 (clientAuth=true)
- 安装了有效客户端证书的 ipad(以 .p12 文件的形式通过电子邮件发送并在配置文件下可见)
通过 ios safari 浏览时,ipad 使用客户端证书并对服务器进行身份验证。
但是在代码中,使用 NSURLConnection,它不会连接。在服务器上调试显示客户端根本没有发送和证书。
在客户端我收到这样的错误:
Request(https://192.168.1.5:8443/device/security/policy>, 0, 0)) didFailWithError:Error Domain=NSURLErrorDomain Code=-1205 "The server “192.168.1.5” did not accept the certificate." UserInfo=0xe2eae30
{NSErrorFailingURLStringKey=https://192.168.1.5:8443/device/security/policy>, NSErrorFailingURLKey=https://192.168.1.5:8443/device/security/policy>, NSLocalizedDescription=The server “192.168.1.5” did not accept the certificate.,
NSUnderlyingError=0xe2eb250 "The server “192.168.1.5” did not accept the certificate.", NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0xe6ab010>}
我知道我可以为 NSURLAuthenticationMethodClientCertificate 保护空间的挑战实现委托方法,但如果我这样做,我没有要发送的证书,它安装在设备上并且无法通过代码访问(是吗??) 我尝试调用 [challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge] 但似乎没有效果。
我原以为 NSURLConnection 会按照 safari 的方式运行并访问已安装的证书,但似乎不是。我不想以某种方式将证书安装到我的应用程序中 - 这就是内置证书管理的用途!
或者我错过了什么?任何帮助表示赞赏。
【问题讨论】:
-
好帖子,但我要做的是避免手动从应用程序包中加载证书。相反,我想使用在操作系统级别安装在设备上的证书
-
您找到解决此问题的方法了吗?我目前正在调查这种完全相同的情况。
-
不,从根本上说,在当前版本的 iOS 中,您无法从应用程序中获取全局安装的证书。 Safari 拥有特殊权利。
标签: ios nsurlconnection nsurlconnectiondelegate