CryptGenKey fails with Access Denied

From: gP T Gr8 (gprasadholla_at_gmail.com)
Date: 09/19/05

  • Next message: ep: "Create a user and specify the SID?"
    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


  • Next message: ep: "Create a user and specify the SID?"

    Relevant Pages

    • VPN configuration question
      ... Plan to build VPN between machines A and B ... we don't know our own RSA key ...
      (comp.os.linux.networking)
    • Re: setting default global.mpt location without Policy
      ... Pat Dotbat wrote: ... I'm trying to apply a setting to a large number of machines to dictate the global.mpt that each uses. ... yet the success of applying this registry setting is barely 50% of machines - it seems that security on that key is such that a non-admin user cannot change it. ... how is the 'Policies' key set, if not via GPO, and if I modify the hku\.default value, how can I force this to apply to any logged on user. ...
      (microsoft.public.project)
    • Re: [SLE] Routing problem
      ... On Friday 22 October 2004 12:55 pm, Paul Ollion wrote: ... > RSA key generation complete. ... Can you still ping between machines? ...
      (SuSE)