简体   繁体   English

通过Alamofire进行SSL固定不起作用

[英]SSL Pinning through Alamofire not working

I'm having some problems in my project with SSL Pinning through Alamofire. 通过Alamofire进行SSL固定时,我的项目遇到了一些问题。 The problem is that in another project created ad-hoc, everything works fine: if Charles is enabled, everything is blocked. 问题在于,在另一个临时创建的项目中,一切正常:如果启用了Charles,则一切都会被阻止。

Now in this project it passes every call, even if my certificate isn't correct. 现在在这个项目中,即使我的证书不正确,它也会通过每个调用。

I thought that maybe the problem is a library imported with my PodFile, but I don't know which one could be. 我以为问题可能出在我的PodFile导入的库中,但是我不知道是哪个库。

I'm asking here because maybe has already had the same problem. 我在这里问是因为也许已经遇到了同样的问题。

Here's the PodFile: 这是PodFile:

pod 'SideMenuController'
pod 'ScrollingStackContainer', '~> 0.5'
pod 'SwiftLocation'
pod 'ObjectMapper'
pod 'ActionSheetPicker-3.0'
pod 'Stripe'
pod 'CocoaMQTT'

pod 'SwiftMessages', '5.0.1'
pod 'PusherSwift'
pod 'CryptoSwift', '~> 0.7.2'
pod 'TTSegmentedControl', '~> 0.3.1'
pod 'Fabric'
pod 'Crashlytics'
pod 'KMPlaceholderTextView', '~> 1.3.0'

pod 'FlowTables',       '~> 0.8.2'

pod 'FBSDKLoginKit'

pod 'KeychainAccess',           '~> 3.1.1'
pod 'ios-ntp',                  '~> 1.1.9'
pod 'MMMaterialDesignSpinner',  '~> 0.2.5'

pod 'Alamofire', '4.7.2'
pod 'Kingfisher',  :git => 'https://github.com/onevcat/Kingfisher.git', :tag => '4.9.0'

Of course everything's blocked when using Charles: that means certificate pinning is working and the app isn't accepting responses that have been intercepted (in this case by Charles). 当然,使用Charles时,所有内容都会被阻止:这意味着证书固定有效,并且该应用程序不接受已被拦截的响应(在本例中为Charles)。 You have a couple options: 您有两种选择:

  1. Disable certificate pinning for debug builds so you can use Charles. 禁用调试构建的证书固定,以便您可以使用Charles。
  2. Export the Charles SSL certificate and include it with debug builds of your app so it becomes one of the pinned certificates. 导出Charles SSL证书,并将其包含在应用程序的调试版本中,使其成为固定证书之一。 Make sure this cert isn't included with your release builds. 确保此证书不包含在您的发行版本中。

I've found the problem: 我发现了问题:

In my PodFile, there was installed also CocoaDebug, a tool which helps you to debug your network calls. 在我的PodFile中,还安装了CocoaDebug,该工具可帮助您调试网络呼叫。 Unfortunately, it overrides my custom SessionManager, and also override methods about SSL certificate pinning. 不幸的是,它覆盖了我的自定义SessionManager,也覆盖了有关SSL证书固定的方法。

It has to be completely uninstalled, it's not enough to disable it in the build. 必须将其完全卸载,仅在构建中禁用它是不够的。

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

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