上述问题的解决方法:
//如果是需要验证自建证书,需要设置为YES
securityPoliy.allowInvalidCertificates =YES;
securityPoliy.validatesDomainName =NO;//不验证证书的域名
HTTPS步骤:
1.从服务器要来.crt格式的证书,然后用Mac钥匙串打开,然后导出.cer格式的证书
2.把.cer证书导入程序的 NSBundle中。
验证证书的代码:
NSString*cerPath = [[NSBundlemainBundle] pathForResource:@"test"ofType:@"cer"];
NSData*cerData = [NSDatadataWithContentsOfFile:cerPath];
NSSet*cerSet = [[NSSetalloc]initWithObjects:cerData,nil];
AFSecurityPolicy *securityPoliy = [AFSecurityPolicy defaultPolicy];
//allowInvalidCertificates 是否允许无效证书(也就是自建的证书),默认为NO
//如果是需要验证自建证书,需要设置为YES
securityPoliy.allowInvalidCertificates =YES;
securityPoliy.validatesDomainName =NO;
//设置证书
[securityPoliy setPinnedCertificates:cerSet];
[dxClient setSecurityPolicy:securityPoliy];
参考:
http://www.cnblogs.com/Crazy-ZY/p/6094383.html
http://www.jianshu.com/p/4102b817ff2f
http://stackoverflow.com/questions/33066819/error-domain-nscocoaerrordomain-code-3840-json-text-did-not-start-with-array-or