iPhone开发:如何实现HTTPS连接?
我正在开发一个 iPhone 项目,需要通过 HTTPS 或 SSL 协议连接到 IIS 服务器。谁能告诉我如何在 iPhone 中实现 HTTPS 连接?任何建议将不胜感激。
先感谢您。
I am working on an iPhone project which need to connect to the IIS server over HTTPS or SSL protocol. Can anyone tell me how to implement HTTPS connection in iPhone? Any advice would be appreciate.
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Ben Copsey 的
ASIHTTPRequest
框架使通过 SSL 发出 Web 请求变得非常简单。稍微修改一下网站的例子:
Ben Copsey's
ASIHTTPRequest
framework makes it trivially easy to issue web requests over SSL.Modifying the site's example slightly:
只需将 NSURLConnection 与指向带有 https 协议的 NUSUL 的 NSURLRequest 一起使用,就像这样:
但我建议您查看 Cocoa 中的 URL 加载系统。
Just use NSURLConnection with an NSURLRequest pointing to an NUSUL with https protocol, just like that:
But I suggest you have a look at the documentation of the URL loading system in Cocoa.
Jason 不要忘记实现 connection:canAuthenticateAgainsProtectionSpace 和 connection:didReceiveAuthenticationChallenge 以确保您正在处理服务器身份验证和客户端身份验证的挑战:
查看这篇文章这将帮助您https://devforums.apple.com/message/143091#143091< /a>
Jason don't forget to implement the connection:canAuthenticateAgainsProtectionSpace and connection:didReceiveAuthenticationChallenge to make sure you're handling the challenges for the Server authentication and Client Authentication:
check out this post that will help you with this https://devforums.apple.com/message/143091#143091
您可能没有公共证书。用firefox/safari/chrome访问https资源能不报错吗?如果不是 - 这就是问题,而不是你的代码。
You probably don't have a public certificate. Can you access the https resource with firefox/safari/chrome without an error? if not - that's the problem, not your code.