CryptGenKey fails with Access Denied
From: gP T Gr8 (gprasadholla_at_gmail.com)
Date: 09/19/05
- Previous message: OShah: "Re: Utility to show ACL information?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: 19 Sep 2005 06:46:20 -0700
I have my app, where i use machine key set and on un installation im
deleting this key set. im exporting the session key from one user to
other in same machine.
The code i have works in some machines, but fails in few machines.
// Acquire context for RSA key
fResult = CryptAcquireContext(&hProv,
CONTAINERNAME,
CSP_PROVIDER,
CSP_PROVIDER_TYPE,
CRYPT_MACHINE_KEYSET);
if (!fResult)
{
// Create a key container if one does not exist.
fResult = CryptAcquireContext(&hProv,
CONTAINERNAME,
CSP_PROVIDER,
CSP_PROVIDER_TYPE,
CRYPT_NEWKEYSET|CRYPT_MACHINE_KEYSET);
if (!fResult)
{
break;
}
}
// get the RSA key handle
fResult = CryptGetUserKey(hProv, AT_KEYEXCHANGE, &hRSAKey);
if (!fResult)
{
if (GetLastError() == NTE_NO_KEY)
{
// Create a key if one does not exist.
fResult = CryptGenKey(hProv,
AT_KEYEXCHANGE,
CRYPT_EXPORTABLE,
&hRSAKey);
if (!fResult)
{
dwErr = GetLastError(); // im getting error here
break;
}
}
else
{
dwErr = GetLastError();
break;
}
}
Im getting Access Denied as error in few machines, and some machines im
getting NTE_FAIL. Point to be noticed is, this was working in all those
machines. but when i reinstalled it, it is not working.
any body have any clue, wats going wrong here?
thanx
- Previous message: OShah: "Re: Utility to show ACL information?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|