ios AFNetworking使用SSL示例 - 固定(要使用哪个文件?) [英] ios AFNetworking using SSL example - pinning (which file to use?)

查看:59
本文介绍了ios AFNetworking使用SSL示例 - 固定(要使用哪个文件?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午全部,



我已经使用网络服务创建了一个简单的应用程序,现在我想使用第三方SSL保护它。我已经安装了SSL并在我的webservice上工作,现在我想要我的iOS项目连接,但我无法弄清楚如何。我已经使用两种不同的方法成功连接并下载到webservice,这样我就可以获得一个体面的理解。 NSURLCONNECTION和AFHTTPSESSIONMANAGER。两者都可以返回相同的结果。



现在我一直在阅读使用这些方法使用SSL的不同帖子。我似乎应该将公共证书安装(固定)到我的应用程序。下面是我发现用作指南的一些代码。我的第一个问题是如何/在哪里将文件拖入我的xcode项目。 (注意我使用的是Microsoft azure web服务)

我去了我购买第三方证书的地方,我可以在那里下载一些东西......似乎是两个不同的文件......一个是中级。这些是我应该固定的文件吗?我还读到有一种方法可以从我的服务器上抓取它们但我不知道怎么做?



有什么想法吗?

谢谢提前!



Afternoon all,

I;ve created a simple app using a webservice and now I want to secure it using a third party SSL. I already have the SSL installed and working on my webservice, now I want my iOS project to connect but I can't figure out how. I've already successfully connected and downloaded to webservice using two different methods just so I can get a decent understanding. NSURLCONNECTION and AFHTTPSESSIONMANAGER. Both work to return the same results.

Now I've been reading different posts on using SSL with those methods. It seems I should install (pin) the public certificate to my app. Below is some code I found to use as a guide. My first question with this is how/where do I get the file to drag into my xcode project. (note I am using Microsoft azure web service)
I went to where I purchased the third party certificate and I can download something there... seems to be two different files... and one is intermediate. Are these the files I am supposed to pin? I also read there is a way to grab them right from my server but I don't know how?

Any ideas?
thanks in advance!

+ (AFSecurityPolicy*)customSecurityPolicy {
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFsslPinningModeNone];
NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"filename" ofType:@"der"];
NSData *certData = [NSData dataWithContentsOfFile:cerPath];
[securityPolicy setAllowInvalidCertificates:NO];
[securityPolicy setValidatesCertificateChain:NO];
[securityPolicy setPinnedCertificates:@[certData]];
return securityPolicy;
}

推荐答案

您找到了解决方案吗?我也在IOS中实现SSL固定。但是不明白怎么做?如果您有解决方案,请使用示例代码发布。我也使用AFnetworking作为目标c
Did you find any solution? I am also implementing SSL pinning in IOS. But cant understand how to do it? If you have the solution kindly post it with sample code. I am also using AFnetworking for objective c


这篇关于ios AFNetworking使用SSL示例 - 固定(要使用哪个文件?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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