Pkcs11Interop / Pkcs11Interop.X509Store

Easy to use PKCS#11 based X.509 certificate store
Apache License 2.0
32 stars 18 forks source link

System.ArgumentNullException: Value cannot be null. (Parameter 'keyHandle') #38

Closed jariq closed 5 months ago

jariq commented 5 months ago

When private key object is not found on the token (e.g. when PIN was not provided) and instance of Pkcs11*Provider is acquired via Get*PublicKey() method, then any method working with private key (e.g. SignHash) throws System.ArgumentNullException: Value cannot be null. (Parameter 'keyHandle').

Situation is exactly the same when public key object is not found on the token (e.g. some tokens do not store public keys) and instance of Pkcs11*Provider is acquired via Get*PrivteKey() method. Any method working with public key (e.g. VerifyHash) throws System.ArgumentNullException: Value cannot be null. (Parameter 'keyHandle').

Better exception should be thrown in this scenarios.