繁体   English   中英

在iOS中验证SSL证书

[英]verify a SSL certificate in iOS

我创建了一个使用https托管的WCF Web服务,我需要使用iPhone应用程序访问此服务。
该服务运行良好,我可以使用浏览器检索数据。 在这种情况下,我需要预先批准证书(“此服务器的证书无效”)
但是在iPhone应用程序中,我无法使其正常运行。
到目前为止,我所做的是:

     - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{
[[challenge sender]continueWithoutCredentialForAuthenticationChallenge:challenge];

}

    - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
NSLog(@"%@",error.description);  }

连接返回错误(准确说明浏览器的内容)
该请求应返回一个字符串或一些非常简单的东西。

此时我该如何进行? 顺便说一句,我使用iOS5.0谢谢

找到它,只需要在connection willSendRequestForAuthenticationChallenge添加另一行connection willSendRequestForAuthenticationChallenge方法

[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM