> In the constructor of WinCAPICryptoProvider, the first call > to CryptAcquiryContext fails with NTE_BAD_KEYSET. After that, > the constructor tries to create one with NEW_KEYSET, which > fails with NTE_EXISTS. (?????)
Keys are corrupted. After you receive NTE_BAD_KEYSET for the first call to CryptAcquireContext, try calling CryptAcquireContext using CRYPT_DELETEKEYSET (to delete the unusable key set if it actually exists), and then call CryptAcquireContext using CRYPT_NEWKEYSET. Hope it helps, Milan