旧iphone 3g上的HTTPS请求 [英] HTTPS request on old iphone 3g

查看:77
本文介绍了旧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

这篇关于旧iphone 3g上的HTTPS请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆