talira

TrustKit

SSL public key pinning and pin-failure reporting for Apple platform apps

open sourceMITfree

TrustKit is an open source framework from Data Theorem that adds SSL public key pinning to iOS, macOS, Mac Catalyst, tvOS, watchOS and visionOS apps written in Swift or Objective-C. A pinning policy, set in Info.plist or in code, pins each domain's Subject Public Key Info hashes, and TrustKit blocks connections whose certificate chain doesn't match. It can report validation failures to a server, and can add pinning to an app's NSURLSession and NSURLConnection delegates automatically without code changes. A separate TrustKit for Android covers Android apps.

Problems it solves

  • stop my iOS app from trusting a forged certificate on a compromised network
  • pin my API's public key in a Swift app and find out when pinning fails in the field
  • add certificate pinning to an existing app without rewriting its networking code

Features

  • pinning policy in Info.plist or in code
  • pins the certificate's Subject Public Key Info hash
  • reports pin validation failures to a server
  • automatic pinning by swizzling NSURLSession and NSURLConnection delegates
  • pin validation for WKWebView through its navigation delegate

Limitations

  • A wrong or outdated pin set stops the app reaching its servers until users install an update, so a backup pin is needed.1
  • Needs iOS 15, macOS 12, tvOS 15, watchOS 9 or visionOS 1 or later.1