Jacob Holm
Jacob Holm

Reputation: 33

pkcs11interop Get error code from exception

I have two cards with different types of tokens. When calling GetTokenInfo() I get CKR_TOKEN_NOT_RECOGNIZED on some tokens. My question is, how do I retrieve this error code in a clean manner?

Snapshot of exception

HResult just indicates General Error. I could check for the exception in the Message string. The RV parameter is not part of the Exception class, not sure which derivative class to use to get this.

Upvotes: 1

Views: 653

Answers (1)

Jacob Holm
Jacob Holm

Reputation: 33

I had forgotten to add a using Net.Pkcs11Interop.Common;

Now I am catching Pkcs11Exception and retrieving the error code through the RV parameter, and comparing it against PKCS#11 error code.

Hope this can help others.

Upvotes: 1

Related Questions