如何在AFNetworking中分配.cer文件? [英] How to assign a .cer file in AFNetworking?
问题描述
我正在使用AFNetworking开发建立HTTPS连接的iPhone应用程序,我想使用我可以定义的自签名证书或可信证书,但我在AFNetworking中找不到任何功能(API)可以做到这一点。
I am using AFNetworking to develop iPhone application that establish HTTPS connections ,I want use self-signed cert or trusted cert I can define ,but I cannot find any function(API) in AFNetworking can do this.
我看到了这个页面:如何使用NSURLConnection连接SSL以获取不受信任的证书?。但我想知道如何分配cer文件?
And I saw this page : How to use NSURLConnection to connect with SSL for an untrusted cert? .But I want to know how to assign a cer file?
谢谢。
推荐答案
好吧,为了简单起见,请按照以下步骤操作
Well, just to be simple, follow this steps
-
将.cer文件复制到项目包中
假设您正在使用
AFHTTPRequestOperation * operation = [[AFHTTPRequestOperation alloc] init。 ..
在该行之后调用以下内容:
Invoke the following after that line:
[操作n setSSLPinningMode:AFSSLPinningModeCertificate]
这将指示AF进行证书固定,无需设置任何其他内容。
This will instruct AF to do Certificate Pinning, no need to set anything else.
这篇关于如何在AFNetworking中分配.cer文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!