配置https证书 用于AFNetworking

后台同事给的事.pem和.key文件,项目中要用cer证书,所以要转一下

pem证书转cer证书 命令: 这里的地址 可以拖拽,比如 cacert.key放在 桌面 从桌面拖拽地址,输出地址同样

1.openssl pkcs12 -export -out cacert.p12 -in cacert.pem -inkey /Users/wangshuai/Desktop/2542654_xmmjq.com.key 先转p12

2.openssl pkcs12 -in cacert.p12 -out mycerts.crt -nokeys -clcerts    再转crt

3.openssl x509 -inform pem -in mycerts.crt -outform der -out mycerts.cer 最后转cer

引用证书代码:

复制代码
复制代码

AFHTTPSessionManager注意一定要 initWithBaseURL 添加baseurl,直接[AFHTTPSessionManager manager]会报错:

A security policy configured with AFSSLPinningModeCertificate can only be applied on a manager with a secure base URL (i.e. https)。闪退

原文地址:https://www.cnblogs.com/frounk/p/9373360.html

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容