限制我的 iPhone 应用程序仅使用一个服务器证书
我的应用程序使用 ASIHttpRequest 进行服务器通信。我要求阻止 HTTP 协议,因为我不习惯通过不安全的链接传输该数据。因此只允许通过 HTTPS 的 SSL。即使链接是 HTTPS,我也需要确保调用正确的证书。所以我需要在我的代码中进行服务器证书验证。请指导我如何做到这一点。
我对此进行了研究。我发现几乎没有可能的答案。一种是创建客户端证书并进行验证。 ASIHttpRequest 文档下还有“客户端证书支持”的方法。那么如何实现我上面的要求呢。将 CFNetwork 代码集成到 ASIHttpRequest 中也可以。
问候,
迪尔山
My application uses ASIHttpRequest for my server communication. I have a requirement that I should block HTTP protocol cos I dont wont to transmit that data over insecure link. So only SSL over HTTPS will be allowed. Also even thought the link is HTTPS I need to ensure that I am calling to the correct certificate. So I need a server certificate validation in my code. Please guide me how to do this.
I researched on this. I found few possible answers. One is to create a client certificate and do the validation. Also there are ways to "Client certificates support" under ASIHttpRequest documentation. So how to achieve my requirements above. Also integration of CFNetwork code into ASIHttpRequest will also do.
Regards,
Dilshan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以从 StartSSL 或 Thawte 等证书颁发机构获取经过验证的证书。然后 iOS 会检查该证书是否受到权威机构的信任。 iOS 具有不同的可信权威。
如果服务器证书未经权威机构验证,连接将被拒绝。
您不需要在代码中做一些特殊的事情。仅使用 https 连接。
You can get a validated certificate from an certificate authority like StartSSL or Thawte. Then iOS checks if the certificate is trusted by an authority. iOS comes with different trusted authorites.
If the server certificate is not validated by an authority the connection is rejected.
You don't need to do something special in code. Only use a https connection.