1

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.

jariq
  • 11,681
  • 3
  • 33
  • 52
Jacob Holm
  • 33
  • 4

1 Answers1

1

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.

jariq
  • 11,681
  • 3
  • 33
  • 52
Jacob Holm
  • 33
  • 4
  • Nice question and correct answer. I tuned markdown formatting of them both to improve reading experience. Don't forget to mark your answer as accepted. – jariq Mar 14 '18 at 05:26