问题描述
我对 SSL 和一般安全连接还很陌生.iOS 应用通过安全通信渠道与服务器通信所需的主要步骤是什么?
I'm fairly new to SSL and secure connections in general. What are the major steps required for an iOS app to talk to a server over a secure communications channel?
我知道可能需要 SSL 证书.我打算从受信任的证书颁发机构购买一个.但是我不确定应用程序和服务器是否都需要证书,或者它只是服务器.另外我不确定如何处理 SSL 错误.也许有一个库可以帮助解决这个问题,比如 ASIHTTPRequest 或类似的.
I'm aware that an SSL certificate will probably be necessary. I'm planning to purchase one from a trusted certificate authority. However I'm not sure if both the app and the server need certificates or if it's just the server. Also I'm not sure how to handle SSL errors. Perhaps there's a library that can help with this like ASIHTTPRequest or similar.
推荐答案
如果您使用 HTTPS 作为通信协议并且在您的服务器上拥有有效的证书,那么所有应该需要的就是更改您的 http://
到您客户端上的 https://
.对于 HTTP 库,现在非常流行的选项是 AFNetworking.它比 ASI 维护得更好,并且具有一些 ASI 不支持的不错的块功能.
If you are using HTTPS as your protocol for communication and have valid certificates on your server all that should be required is changing your http://
to https://
on your client. For HTTP libraries a very popular option now is AFNetworking. It is a bit better maintained than ASI and has some nice block features not supported by ASI.
就 SSL 错误而言,向最终用户显示警告通常是一个好主意(通过警报视图或其他方式).它们可能指向真正的安全攻击(但更有可能指向未配置或过期的证书).
As far as SSL errors, it is usually a good idea to present the warnings to end users (through alert views or some other means). They could point to real security attacks (but more likely will point to miss configured or expired certificates).
这篇关于从 iOS 应用程序到服务器的 SSL 通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!