CryptAcquireContext - Object already exists Error

From: Carmit (carmitm_at_mail.com)
Date: 09/23/04


Date: 23 Sep 2004 02:22:05 -0700

Hi,

I'm trying to use Crypto API in a COM object.
 
Here is some of my code:

if(!CryptAcquireContext(&hCryptProv, password, NULL, PROV_RSA_FULL,
CRYPT_MACHINE_KEYSET))
{
        //need to create a new key container
        if(!CryptAcquireContext(&hCryptProv, password, NULL, PROV_RSA_FULL,
                                                                CRYPT_NEWKEYSET | CRYPT_MACHINE_KEYSET ))
                {
                        hr = E_FAIL;
                        ...
                        return hr;
                }
                        
        }
}

When trying to use my COM object from an ASP web page everything is
great, but when I'm trying to use it from another application (let's
say a VB application), I get an error that my key container already
exists.

I understood that using CRYPT_MACHINE_KEYSET flag should allow me to
use this key container from different applications on the same
machine.

Any help would be appriciated.

Thanks,
Carmit



Relevant Pages


Quantcast