简体   繁体   English

斯威夫特AlamoFire的ssl钉扎

[英]ssl pinning in Swift AlamoFire

Im a newb here but I have an app that is subject to MITM attacks. 我是一个新手,但我有一个受MITM攻击的应用程序。

After I bit of research it sounds like I need to do SSL Pining, ie keep a copy of my servers public key/certificate so the can determine if the response came from it. 在我进行一些研究之后,听起来我需要进行SSL Pining,即保留我的服务器公钥/证书的副本,以便可以确定响应是否来自它。

I have no idea how to do this, I am using AlamoFire in Swift to handle the networking. 我不知道怎么做,我在Swift中使用AlamoFire来处理网络。

Alamofire now implemented the certificate pinning. Alamofire现在实施了证书固定。 The documentation you need is in the Readme.md 您需要的文档位于Readme.md中

https://github.com/Alamofire/Alamofire https://github.com/Alamofire/Alamofire

See their example implementation: 查看他们的示例实现:

let serverTrustPolicies: [String: ServerTrustPolicy] = [
    "test.example.com": .PinCertificates(
        certificates: ServerTrustPolicy.certificatesInBundle(),
        validateCertificateChain: true,
        validateHost: true
    ),
    "insecure.expired-apis.com": .DisableEvaluation
]

let manager = Manager(
    serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies)
)

As indicated here : https://github.com/Alamofire/Alamofire/issues/366 如下所示: https//github.com/Alamofire/Alamofire/issues/366

It is certainly something that the community is looking to support, but there's not a solid time frame around it yet. 这当然是社区希望支持的东西,但目前还没有坚实的时间框架。 I'd say for the time being, you'll want to continue with AFNetworking, and keep a close eye on the Alamofire project for new features coming in. 我暂时说,你会想继续使用AFNetworking,并密切关注Alamofire项目的新功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM