ios项目绕过证书访问https程序
来源:互联网 发布:最好用的收银软件 编辑:程序博客网 时间:2024/05/16 07:15
如果是单个的webview或者request请求,在请求的文件h中直接实现NSURLConnectionDelegate,并在m中添加下列实现下列两个方法:
- - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
- return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
- }
- - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
- if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
- //if ([trustedHosts containsObject:challenge.protectionSpace.host])
- [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]
- forAuthenticationChallenge:challenge];
- [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
- }
上述方法很不爽的是每个请求的地方都要加。
如果项目中用到了three20,直接修改“TTRequestLoader.m”即可,这个文件本身就已经实现了NSURLConnectionDelegate,
修改如下,只改这一个地方就行,处处可用。
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- - (void)connection:(NSURLConnection *)connection
- didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{
- //修改
- if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
- [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
- [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
- TTDCONDITIONLOG(TTDFLAG_URLREQUEST, @" RECEIVED AUTH CHALLENGE LOADING %@ ", _urlPath);
- [_queue loader:self didReceiveAuthenticationChallenge:challenge];
- }
- //添加
- - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
- return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
- }
- ios项目绕过证书访问https程序
- 关于ios项目绕过证书访问https
- iOS UIWebView 访问https 绕过证书验证的方法
- iOS UIWebView 访问https 绕过证书验证的方法
- iOS UIWebView 访问https绕过证书验证的方法
- 访问https 绕过证书验证的方法
- java绕过证书验证访问https
- webView绕过信任证书访问https
- 访问https 绕过证书验证方法
- https请求绕过证书
- HTTPS绕过证书
- java https绕过服务器端证书
- java https绕过服务器端证书
- 绕过证书校验https协议URL
- webservice 绕过证书验证调用https接口
- HttpClient配置SSL绕过https证书
- https自建证书访问
- Java程序避开SSL证书问题访问https网站
- Shell笔记
- 【Android 开发教程】FrameLayout帧布局
- Android Context 使用时注意内存泄漏问题
- iPhone第三方框架Three20简介
- careercup5.6
- ios项目绕过证书访问https程序
- serial
- sqlite3中的数据类型
- DEFERRED IMMEDIATE
- 【Android 开发教程】ScrollView滚动视图
- 星星点灯
- Three20的安装过程
- 每两部Andriod智能手机里,就有一部是三星
- hive 中的多列进行group by查询方法