PeculiarVentures / pvpkcs11

pvpkcs11 consists of a input validation library and a set of PKCS#11 implementations that wrap operating system and browser cryptographic implementations.
MIT License
32 stars 7 forks source link

App is crashed on using keys of apple certs #27

Closed microshine closed 6 years ago

microshine commented 6 years ago

App was crashed on iPhone Developer cert

microshine commented 6 years ago

there wasn't check for returned value from SecKeyCopyPublicKey function in FillPublicKeyStruct

microshine commented 6 years ago

This makes it unnecessary to store the public key in the keychain. In the rare case of a failure, the function doesn’t create an error object, but the public key reference is nil. This might happen, for example, if the private key resides on a smart card that is no longer attached to the system, and is thus unavailable. source

@rmhrisk Should I hide such certificates and private keys?

rmhrisk commented 6 years ago

We should not hide them but expose to the caller that this key doesn't have private key any longer

microshine commented 6 years ago

I've got this error for certificates from GlobalSign and StartCom. Certificates were installed from pfx

microshine commented 6 years ago

All private keys which throws error on SecKeyCopyPublicKey don't have public key in KeyChain