旧iphone 3g上的HTTPS请求
其他任何人在使用旧iphone上的https请求时遇到问题。
Anyone else having issues with getting a https request working on the old iphone.
从连接失败并显示错误,错误消息如下。
From connection did fail with error the error message is as follows.
带有连接的错误:错误域= NSURLErrorDomain代码= -1202此服务器的证书无效。您可能正在连接到假装的服务器是www.ourwesbite.co.uk,可能会使您的机密信息面临风险。
ERROR with theConnection:Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be "www.ourwesbite.co.uk" which could put your confidential information at risk."
我们的网站有效证书,这个问题也不会出现在任何新的iphone / ipod touch或ipads中,只有最老的iphone。
The "ourwebsite" has a valid certificate and also this problem does not arise in any new iphone/ipod touch or ipads just the oldest iphones.
这会影响我的登录工作,因为抛出一个连接错误用户单击确定登录过程正常运行的连接错误警报。但问题是它在登录后会影响用户界面。
This is affecting my login from working by throwing a connection error after user clicks ok to the connection error alert the login process runs through fine. But the problem is its affecting the UI after the login.
所以非常想知道是否有其他人在使用旧款iphone时遇到类似问题。我的代码没有问题,因为它在模拟器上工作得很好。 ipad / 4gen ipod touch。
So pretty much want to know if anyone else is having issues like this with the old iphone. There is no problem with my code as it works perfectly fine on simulator & ipad/4gen ipod touch.
谢谢
好吧甚至如果证书有效,它将抛出错误。所以使用NSURLConnection的以下委托方法解决了这个问题。
Ok so even tho the certificate is valid it will throws the error. So using the following delegate method for NSURLConnection solved this problem.
-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{
当对身份验证提出质疑时,它会被调用。以下代码允许继续使用https连接。
it gets called when there is a challenge to the authentication. The the following bit of code allow's it to continue with the https connection.
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
然后如果感觉不受信任则允许连接
And then that allows the connection through if it feels it is untrusted