Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on "unsupported public key algorithm" #211

Closed
boehlefeld opened this issue Sep 30, 2019 · 2 comments
Closed

Crash on "unsupported public key algorithm" #211

boehlefeld opened this issue Sep 30, 2019 · 2 comments

Comments

@boehlefeld
Copy link

Hey,

I rarely run on production into an unknown key algorithm issue regarding the crash logs. Cannot reproduce the issue, so can't tell which domain and which public key algorithm.

@throw([NSException exceptionWithName:@"Unsupported public key algorithm" reason:@"Tried to generate the SPKI hash for an unsupported key algorithm" userInfo:nil]);

I don't get why this goes into a crash at all. Whats the best way to handle this issue?

Trustkit 1.6.1 / iOS 13.1, iOS 12.4.1 / iPhone 7

0   CoreFoundation                	0x234dae98c __exceptionPreprocess + 228 (NSException.m:172)
1   libobjc.A.dylib               	0x233f879f8 objc_exception_throw + 56 (objc-exception.mm:557)
2   TrustKit                      	0x103d97e3c -[TSKSPKIHashCache hashSubjectPublicKeyInfoFromCertificate:] + 1572 (TSKSPKIHashCache.m:67)
3   TrustKit                      	0x103d9758c verifyPublicKeyPin + 388 (ssl_pin_verifier.m:71)
4   TrustKit                      	0x103d9ece0 -[TSKPinningValidator evaluateTrust:forHostname:] + 540 (TSKPinningValidator.m:126)
5   TrustKit                      	0x103d9f0b8 -[TSKPinningValidator handleChallenge:completionHandler:] + 288 (TSKPinningValidator.m:202)
@joshrl
Copy link

joshrl commented Dec 5, 2019

Also seeing an intermittent crash that looks similar

Trustkit 1.6.1
13.2.3, 13.2
iPhone 6S, iPhone XS

Unsupported public key algorithm
(null)

0 CoreFoundation 0x12b80c __exceptionPreprocess + 220
1 libobjc.A.dylib 0x5fa4 objc_exception_throw + 56
2 TrustKit 0x10323bb84 -[TSKSPKIHashCache hashSubjectPublicKeyInfoFromCertificate:] + 1604
3 TrustKit 0x10323b2cc verifyPublicKeyPin + 388
4 TrustKit 0x1032425a4 -[TSKPinningValidator evaluateTrust:forHostname:] + 540
5 TrustKit 0x103242974 -[TSKPinningValidator handleChallenge:completionHandler:] + 288

@nabla-c0d3 nabla-c0d3 changed the title Unsupported public key algorithm Crash on "unsupported public key algorithm" Sep 13, 2020
@nabla-c0d3
Copy link
Member

Released as v1.7.0.

OS-ricardomoreirasilva added a commit to OutSystems/TrustKit that referenced this issue Oct 28, 2024
* Fix iOS version; fixes datatheorem#181

* Fix 1 bug, and several static analysis warnings
If shouldExcludeSubdomain is explicitely set to NO, it was treated the
same as YES

* Pod update Demo App to TrustKit 1.6

* Add default circle ci 2.0 file

* Fix CI

* Fix CI

* Fix CI

* Switch to bitrise

* Bump version number

* Update Podfile in demo app to 1.6.1

* Fix test for testPinningValidationSucceeded

This test had an outdated pinset which caused it to fail.
Updated the pinset to include a pin from the current intermediate
CA certificate (Let's Encrypt Authority X3)

* Fix domain selection in overlapping pinsets

Observed behavior of TrustKit showed that, when a domain did not
have an exact match for a pinset, the first matching pinset config
with the IncludeSubdomains flag was selected. This led to
unpredictable behavior because of the nature of iterating through
dictionary keys. The change in this commit modifies TrustKit's
selection algorithm to iterate through all pinset configs and then
select the one that is the closest match (e.g, longest domain).
This matches the industry best practice set by Google in their
native Android pinning implementation, and brings TrustKit's
behavior in line with that of TrustKit-Android.

* [datatheorem#201] Fix pinning configuration in test apps

* Adding DEFINES_MODULE Flags

Currently TrustKit can't be packaged in a static Swift Library without modules.
"Pod package" fail if TrustKit is in other podspec dependency.
Addind this line will generate module maps for swift dependencies.

* Bump version number

* Re-generate documentation

* Update TrustKit in demo app

* Save & load the SPKI disk cache using secure coding.

* Don't rely on external variable for memory allocation

* Replace static allocation with a runtime check

* Re-generate test certificates and simplify tests

* Log decoding error

* Fix remaining tests

* Add script for generating test certificates

* Fix secure coding deserialization

* Fix secure coding deserialization on non-iOS platforms

* Xcode recommended fixes

* Xcode recommended fixes

* Xcode recommended settings

* Bump version number

* Update TrustKit in demo app

* Added SPM support

* Fixed CocoaPods support

* Fixed tests

* Fixed issue with path to TrustKit.h

* Fix location of TrustKit.h for CocoaPods; fixes datatheorem#216

* Bump version number

* Update demo app

* Remove outdated link

* Fix getting started completionHandler unnecessary key

* Fixed SPM support

Signed-off-by: Mohammad Porooshani <porooshani@gmail.com>

* Fixed Tests and pod support

Signed-off-by: Mohammad Porooshani <porooshani@gmail.com>

* Bump version number

* Update demo app

* Fix framework to package /Modules files when built

Public headers were added to the xcodeproj file in a way that
a modulemap was no longer being generated, and therefore no
swiftmodule (or swiftinterface) file could be created. This adds
them as explicit public headers instead of a folder copy.

* [datatheorem#210] Fix crash when passing a TLD to check config

* [datatheorem#211] Do not crash on an unsupported key

* [datatheorem#232] Remove non-secure NSKeyedArchiver code

* Fix build warning

* Bump version number

* Update Demo app

* Remove extra spaces

* Add Swift Package Manager to the installation instructions

* [datatheorem#234] Expost static and dynamic Swift packages

* Update README.md

Clarify sample config

* Added a nil check for the value returned from SecCertificateCopySubjectSummary before logging and releasing the value

* Added log for when the certificate subject could not be parsed.

* Added error checking when copying the public key from the certificate.

* Update pinned certs in unit tests

* Update OCMock framework

* Update project settings

* Update CocoaPods

* Bump version number

* Fix pins in demo apps

* Update demo apps settings

* Update demo apps TrustKit version

* Use NS_BLOCK_ASSERTIONS for SwiftPM release builds

Xcode doesn't automatically set the NS_BLOCK_ASSERTIONS flag for SwiftPM release builds.

Use cSettings to set the flag, so NSAssert doesn't crash release builds and behavior is similar to using Carthage or Cocoapods.

See https://forums.swift.org/t/assertions-in-swift-packages/42692 for more info.

* Bump version number

* Update Demo app to use last version of TrustKit

* Update Demo app Xcode settings

* fix deprecation warnings

Fixes deprecation warnings for

  - SecTrustEvaluate
  - SecTrustGetCertificateAtIndex
  - SecTrustCopyPublicKey

* add header/source references for pinning_utils

* remove deprecated references to +[NSURLSession new]

* use dlsym and ifdefs for SecTrustCopyCertificateChain on old SDKs

* tvos, watchos min versions

* check for null error in evaluateTrust

* remove SecEvaluateTrust, bump min OS versions in readme

* remove SecTrustCopyPublicKey, bump min OS versions

* refactor SecTrustEvaluateWithError, bump OS versions, update readme

* evaluate status instead of trustResult of TSKSPKIHashCache

* bump version, update podspec, update Xcode demo app

* update OS versions, swift tools version in SPM package

* enable multipath service type handover on iOS for all NSURLSessions

* avoid using IDFV on iOS and tvOS

* restore iOS 12, tvOS 12, watchOS 4, macOS 10.13 support

* remove easily-misinterpreted bool return value

* restore earlier OS versions in package manager

* fix pod lib lint warnings

* Fix for Trustkit not building on Xcode 14.3 datatheorem#298

* lower deployment versions, fix misc warnings

* Fix for crash reported on iOS 17

* Load library from complete path if loading from default path failed

* use full path for security framework

* bump version to 3.0.3

* Add Privacy Manifest

Fixes datatheorem#319

* Add missing entries to PrivacyInfo.xcprivacy

- Swap Cloudflare domain with Data Theorem for TSKEndToEndSwizzlingTests
- Add PrivacyInfo.xcprivacy to Xcode project for all targets
- Remove noop assign

* Bump version to 3.0.4

* chore: update podspec

* chore: update framework name

This is the name to use when we need to import the library as a xcframework, instead of a CocoaPod.

* chore: add CHANGELOG entry

References: https://outsystemsrd.atlassian.net/browse/RMET-3403

---------

Signed-off-by: Mohammad Porooshani <porooshani@gmail.com>
Co-authored-by: Alban Diquet <ad@sourcetheorem.com>
Co-authored-by: Adam Kaplan <adamkaplan@yahoo-inc.com>
Co-authored-by: Alban Diquet <nabla.c0d3@gmail.com>
Co-authored-by: Joe Portner <jpportner@gmail.com>
Co-authored-by: AbbyM <mehdi.abby@gmail.com>
Co-authored-by: Adam Kaplan <adamkaplan@verizonmedia.com>
Co-authored-by: Peter Gammelgaard Poulsen <peter.gammelgaard@gmail.com>
Co-authored-by: luancurti <luancurti@gmail.com>
Co-authored-by: Mohammad Porooshani <porooshani@gmail.com>
Co-authored-by: David Harris <davidaharris@outlook.com>
Co-authored-by: Craig Siemens <siemens.craig@gmail.com>
Co-authored-by: Ethan Arbuckle <ea@sourcetheorem.com>
Co-authored-by: Alban Diquet <ad@datatheorem.io>
Co-authored-by: Eric Chamberlain <eric.chamberlain@gmail.com>
Co-authored-by: Amos Joshua <aj@datatheorem.io>
Co-authored-by: pawisoon <pawi552@gmail.com>
Co-authored-by: Darsan-G <darsang@gmail.com>
Co-authored-by: aj-dt <125371080+aj-dt@users.noreply.github.com>
Co-authored-by: uroboro <uroboro845@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants