博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
让asihttprequest v1.8.1-61支持tlsV1.0 sslV3
阅读量:5925 次
发布时间:2019-06-19

本文共 1401 字,大约阅读时间需要 4 分钟。

现象:

  访问google places api,返回错误:

    ASIHTTPRequestErrorDomain Code=1 *** SSL problem ****

 

解决方法:

方法:startRequest

        if (![self validatesSecureCertificate]) {

            // see: http://iphonedevelopment.blogspot.com/2010/05/nsstream-tcp-and-ssl.html
            
            NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
                                      [NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredCertificates,
                                      [NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot,
                                      [NSNumber numberWithBool:NO],  kCFStreamSSLValidatesCertificateChain,
                                      kCFNull,kCFStreamSSLPeerName,
                                      nil];
            
            CFReadStreamSetProperty((CFReadStreamRef)[self readStream],
                                    kCFStreamPropertySSLSettings,
                                    (CFTypeRef)sslProperties);
            [sslProperties release];
        }

加上一行:

 

        if (![self validatesSecureCertificate]) {

            // see: http://iphonedevelopment.blogspot.com/2010/05/nsstream-tcp-and-ssl.html
            
            NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
                                      [NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredCertificates,
                                      [NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot,
                                      [NSNumber numberWithBool:NO],  kCFStreamSSLValidatesCertificateChain,
                                      kCFNull,kCFStreamSSLPeerName,
                                           @"kCFStreamSocketSecurityLevelTLSv1_0SSLv3", kCFStreamSSLLevel,
                                      nil];
            
            CFReadStreamSetProperty((CFReadStreamRef)[self readStream],
                                    kCFStreamPropertySSLSettings,
                                    (CFTypeRef)sslProperties);
            [sslProperties release];
        }

转载于:https://www.cnblogs.com/felixYeou/archive/2012/07/23/2605540.html

你可能感兴趣的文章
案例12: 分页
查看>>
android Nine-Patch的使用(制作聊天界面必学)
查看>>
生成环境安全加固项
查看>>
引跑科技助力传统企业构建大数据价值体系
查看>>
rpm、yum工具的介绍和用法
查看>>
java 调用cmd
查看>>
我的友情链接
查看>>
javaIO
查看>>
我的友情链接
查看>>
apache prefork模式优化错误
查看>>
如何开发一个 PyCharm 插件
查看>>
yum的使用
查看>>
创建可扩展性系统-7-1
查看>>
jQuery 选择框 Selectator
查看>>
土豆 GhostXP SP3 系统2012新年纯净版V1
查看>>
Java对Map排序
查看>>
linxu send out main
查看>>
数据路由,你造吗?
查看>>
java Bean import 学习笔记
查看>>
elk
查看>>