SwiftyRSA: RSA private key creation from data failed code=-50

I am currently trying to create a PrivateKey from a base64 encoded key via base64Encoded and pemEncoded. Since I always received the Couldn't create key reference from key data SwiftyRSAError, I decided to check for more meaningful errors and found that no matter the key I pass in, I always get the error listed in the title.

The change to see this error is found in SwiftyRSA.addKey within the iOS 10.0 if block.

Change guard let key = SecKeyCreateWithData(keyData as CFData, keyDict as CFDictionary, nil) to

var error:Unmanaged<CFError>? = nil
guard let key = SecKeyCreateWithData(keyData as CFData, keyDict as CFDictionary, &error) else {
  print(error)
...
}

I have tested this with about 20 different RSA private keys as well as those found in the test key folder. I am not sure if I am going on the wrong track or not.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 23 (10 by maintainers)

Most upvoted comments

@ldiqual Any idea how to resolve that?