datatheorem / TrustKit

Easy SSL pinning validation and reporting for iOS, macOS, tvOS and watchOS.
MIT License
2.01k stars 362 forks source link

Crash in TSKSPKIHashCache.m line 234 #261

Closed tadija closed 2 years ago

tadija commented 3 years ago

Hi,

lately we noticed increased crash rate coming from TrustKit (in thousands, although I could never reproduce it locally).

At first I thought it's related to #248 or #249 so when 2.0.0 release came out I updated TrustKit dependency hoping that it brings a fix for this and closed the crash on Crashlytics.

Unfortunately, we keep getting the crash afterwards and apparently now it comes from this line: https://github.com/datatheorem/TrustKit/blob/c7c9271ec1ec3996b4a9a719972c0098c9886716/TrustKit/Pinning/TSKSPKIHashCache.m#L234

I suspect it might have something to do with "Data Protection" capability being enabled in our project (ie. disk locked at the moment of writing cache) but I'm not sure how (or where) to fix it. Any ideas?

mflint commented 3 years ago

Using NSAssert here, when failing to write to the cache, feels a little excessive.

Is crashing really the best option here?

echamberlain commented 2 years ago

I have a PR up to fix the build settings when using SwiftPM. SwiftPM doesn't set NS_BLOCK_ASSERTIONS by default.

nabla-c0d3 commented 2 years ago

I just released the fix as part of v2.0.1 (https://github.com/datatheorem/TrustKit/releases/tag/2.0.1). Thanks for your patience!