Click here to Skip to main content
15,918,742 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: On Combo Box Pin
Rajkumar R27-Mar-08 1:10
Rajkumar R27-Mar-08 1:10 
GeneralRe: On Combo Box Pin
Chandrasekharan P27-Mar-08 6:17
Chandrasekharan P27-Mar-08 6:17 
GeneralRe: On Combo Box Pin
Rajkumar R27-Mar-08 6:41
Rajkumar R27-Mar-08 6:41 
GeneralRe: On Combo Box Pin
Stephen Hewitt27-Mar-08 15:21
Stephen Hewitt27-Mar-08 15:21 
GeneralRe: On Combo Box Pin
Chandrasekharan P27-Mar-08 16:34
Chandrasekharan P27-Mar-08 16:34 
QuestionHow to Create Setup of VC++ application? Pin
Lakul27-Mar-08 0:29
Lakul27-Mar-08 0:29 
AnswerRe: How to Create Setup of VC++ application? Pin
Rajesh R Subramanian27-Mar-08 2:05
professionalRajesh R Subramanian27-Mar-08 2:05 
QuestionCryptAcquireContext fails with NTE_BAD_KEY_STATE Pin
Rajesh_Parameswaran27-Mar-08 0:23
Rajesh_Parameswaran27-Mar-08 0:23 
Hi,

My application fails after making a call to the Windows CryptAcquireContext API. I get the following error code NTE_BAD_KEY_STATE ( 0x8009000BL ).

Code snippet and details below:

////////////////////////////////////////////////////////////////////////////////

/* @func UINT32 | get_key |
* Description: Get encryption key. In order to do this need to
* acquire encryption context and hashing object.
*
*---------------------------------------------------------------------
*/
////////////////////////////////////////////////////////////////////////////////
UINT32 get_key(TCHAR * szPassword, HCRYPTPROV * phProv,
HCRYPTHASH * phHash, HCRYPTKEY * phKey)
{
...
...
// Get handle to user default provider.
rc = CryptAcquireContext(phProv, NULL, MS_DEF_PROV, PROV_RSA_FULL, 0);
if(!rc)
{
lRet = GetLastError();

if (lRet == NTE_BAD_KEYSET)
{
// create default key container
if (!CryptAcquireContext(phProv, NULL, MS_DEF_PROV, PROV_RSA_FULL,
CRYPT_NEWKEYSET))
{
lRet = GetLastError();
}
}
}
...
...
}

The first call to CryptAcquireContext() here fails with NTE_BAD_KEY_STATE, and there isn't sufficient information available on MSDN bout the error code. All I got was that the error returned from the failing API suggests that the user password has changed since the private keys were encrypted. But there weren't any sort of user modifications done recently on my machine.

The issue occurs on a Win2K3 HP server. But it seems to be happening only on one of my servers and works fine on others.

Any ideas as to what might be going wrong here? I know that re-installing the OS here would fix this (cause it happened on another machine in the past and the only way out that time was re-installing the OS). But re-installing the OS here would mean a lot of work to be re-done at this point for me. Has anyone encountered such a problem in the past, if so, how was it resolved?

Thanks in advance!
- Benson
Generalchanging shortcut name Pin
neha.agarwal2727-Mar-08 0:00
neha.agarwal2727-Mar-08 0:00 
GeneralRe: changing shortcut name Pin
Rajkumar R27-Mar-08 0:24
Rajkumar R27-Mar-08 0:24 
Generalavoid passwords Pin
kendals26-Mar-08 23:49
kendals26-Mar-08 23:49 
GeneralRe: avoid passwords Pin
Iain Clarke, Warrior Programmer27-Mar-08 1:19
Iain Clarke, Warrior Programmer27-Mar-08 1:19 
GeneralRe: avoid passwords Pin
kendals27-Mar-08 3:46
kendals27-Mar-08 3:46 
GeneralRe: avoid passwords Pin
Iain Clarke, Warrior Programmer27-Mar-08 3:58
Iain Clarke, Warrior Programmer27-Mar-08 3:58 
GeneralRe: avoid passwords Pin
kendals27-Mar-08 4:04
kendals27-Mar-08 4:04 
GeneralRe: avoid passwords Pin
Iain Clarke, Warrior Programmer27-Mar-08 4:26
Iain Clarke, Warrior Programmer27-Mar-08 4:26 
GeneralRe: avoid passwords Pin
kendals27-Mar-08 4:28
kendals27-Mar-08 4:28 
GeneralRe: avoid passwords Pin
Iain Clarke, Warrior Programmer27-Mar-08 22:50
Iain Clarke, Warrior Programmer27-Mar-08 22:50 
QuestionPlease help me Pin
Member 417463926-Mar-08 23:38
Member 417463926-Mar-08 23:38 
QuestionRe: Please help me Pin
Rajesh R Subramanian26-Mar-08 23:42
professionalRajesh R Subramanian26-Mar-08 23:42 
GeneralRe: Please help me Pin
Maxwell Chen26-Mar-08 23:59
Maxwell Chen26-Mar-08 23:59 
GeneralRe: Please help me Pin
Rajkumar R27-Mar-08 0:54
Rajkumar R27-Mar-08 0:54 
GeneralTransparency in DirectDraw Pin
Hanan88826-Mar-08 22:58
Hanan88826-Mar-08 22:58 
GeneralRe: Transparency in DirectDraw Pin
Rajkumar R27-Mar-08 0:58
Rajkumar R27-Mar-08 0:58 
GeneralHelp, how to delete nodes xml in c# Pin
woke26-Mar-08 22:45
woke26-Mar-08 22:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.