JWT: JWTCryptoSecurity : addKeyWithData method doesn't work on iOS 9

Issue Info

Info Value
Platform Name ios
Platform Version 9.0
Xcode Version Xcode 9
Repro rate (100%)

Issue Description and Steps

Hi guys, we are working on react-native codepush plugin and we are using your library to verify JWT signature. Our customers reported that iOS9 is not working correctly when calling this method: https://github.com/Microsoft/react-native-code-push/blob/master/ios/CodePush/CodePushUpdateUtils.m#L327

It appears that JWTCryptoSecurity : addKeyWithData is not working on iOS 8-9 for us. While SecKeyCreateWithData is not available on SDK < 10 we are going on this else switch: https://github.com/yourkarma/JWT/blob/a8829959acd7fbc79bdb47f433e3b9243e1c304f/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m#L80

When calling https://github.com/yourkarma/JWT/blob/a8829959acd7fbc79bdb47f433e3b9243e1c304f/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m#L111 it always return null for key.

Method params are as follows:

(lldb) po [self dictionaryByCombiningDictionaries:@[attributes, commonAttributes, copyAttributes]]
{
    atag = <65383432 39396261 63616336 34396434 39633463 36626530 32653435 39306463>;
    bsiz = 550;
    class = keys;
    kcls = 0;
    pdmn = ak;
    "r_Ref" = 1;
    type = 42;
}

Probably the issue could be related to this thread: https://forums.developer.apple.com/thread/13748

Public/Private key pair was generated via openssl.

private key (click to expand)

-----BEGIN RSA PRIVATE KEY-----
MIIJKQIBAAKCAgEAw6+tlsxhCX9q51MVqrdde3Nr20ldLoL63ATJjXfPOGDyzuTy
Nx5fMwCzA32y/fL4ThAY6tDtDrxIt9dSldllCq7wFdvUnlB1nKy4g3J9j+6FyZIw
UbJniNw+S51NcKYyU/JVhSqjNlN94N7dLetmtGmHKwqXonI3hS+4LDsA5hrKyXzs
0PmYoJAcp9t+WGL4GlW0gEEJztNzPLa7E0iO8irQTzOmiAwoSt15m6nIPhvMSiT5
hxaqBdNZO8NzGPGD9cpHagQmZaQrTMRZUSuD7laa2/xjvg41p80fdHdsRCLsTthG
1zHdQAjvALMh4E3AEw933Ax9wcG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FnKLnuYamZRGqfT2RJzNN6ZDUtx41UKrkSNMON4W4VGvbpuyWh_MwSy6TlJ6pREcQF6S8sufNDAWPYfg_l9S_8x64D1g0n9YMVaMQqj3PSWTWU8Qt8wvjo4KL4JWmiAJv1SyfGkciBBNU7xdEM--TUdkQoY829e0nqxqkHndheDQKtfTUo3n4q3Wj9LPL_LYqD9iBwn9bcIUfaHklyE_K9h9z-ZE

Please let me know if you have any ideas on how to fix this or if you need more info regarding this.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

@max-mironov nice work! let’s merge it!