I am getting an 8219 (0x201B) error when trying to use system certificate for signing. Still I am able to use this certificate with other applications. Am I doing something wrong?
This problem sometimes occurs on 64 bit operating systems when accessing certificates stored on hardware tokens with TElWinCertStorage object. Some token vendors only implement 32 bit CSP's for their tokens, leaving x64 version aside. (CSP is a driver that sets up an interaction between CryptoAPI and the hardware token). When a 64 bit process attempts to use such certificate for signing, the system fails to find an appropriate 64 bit CSP to request a signing operation from, and returns an error. You can check if this is the case by changing the target platform of your .NET project to x86 (instead of AnyCPU or x64) and trying to perform signing in this mode. If the project signs data flawlessly in x86 mode but doesn't in x64/AnyCPU mode, then the driver is the reason.