magiclabs / magic-ios

MagicSDK library for IOS
Apache License 2.0
7 stars 8 forks source link

Tackle crash defensively in the case of an invalid signature of a keychain value #35

Closed tristan-warner-smith closed 7 months ago

tristan-warner-smith commented 7 months ago

We encounter a recurring crash on this implicitly unwrapped try!. The cause, seems to be an OS-bug that indicates the biometrics that are securing the keychain have changed, such as when an app is automatically restored on a new phone.

The throwing function that gets the privateKey does not throw in this situation but the signature is invalid so it crashes here.

The recommendation in the forum seems to be to delete the keychain value in this scenario, but I don't have sufficient context to know if what I do in this PR is sufficient to recreate the keychain value.

What I do know is that this error results in users being unable to use the app at all, until they uninstall + reinstall the app, which is a terrible user experience.

tristan-warner-smith commented 7 months ago

For context:

getIdToken crash Logout crash
romin-halltari commented 7 months ago

Thank you @tristan-warner-smith for this PR. We checked it on our end and it solves the issue with runtime crashes when the signing fails.

tristan-warner-smith commented 7 months ago

Thank you @tristan-warner-smith for this PR. We checked it on our end and it solves the issue with runtime crashes when the signing fails.

Great, and no chance of it popping up in other places? You don't need to delete the previous key etc? Changes to that key should persist correctly etc @romin-halltari ?