Error During Cryptacquirecontext For A New Key Container
Contents |
360 games PC games cryptacquirecontext example Windows games Windows phone games Entertainment All Entertainment cryptacquirecontext c# Movies & TV Music Business & Education Business Students & educators
Cryptacquirecontext Failed Windows 7
Developers Sale Sale Find a store Gift cards Products Software & services Windows Office Free downloads & security Internet
Cryptacquirecontexta
Explorer Microsoft Edge Skype OneNote OneDrive Microsoft Health MSN Bing Microsoft Groove Microsoft Movies & TV Devices & Xbox All Microsoft devices Microsoft Surface All Windows PCs & tablets PC accessories Xbox & games Microsoft Lumia All cryptacquirecontext nte_bad_keyset Windows phones Microsoft HoloLens For business Cloud Platform Microsoft Azure Microsoft Dynamics Windows for business Office for business Skype for business Surface for business Enterprise solutions Small business solutions Find a solutions provider Volume Licensing For developers & IT pros Develop Windows apps Microsoft Azure MSDN TechNet Visual Studio For students & educators Office for students OneNote in classroom Shop PCs & tablets perfect for students Microsoft in Education Support Sign in Cart Cart Javascript is disabled Please enable javascript and refresh the page Cookies are disabled Please enable cookies and refresh the page CV: {{ getCv() }} English (United States) Terms of use Privacy & cookies Trademarks © 2016 Microsoft
Campos MagencioMay 27, 20082 0 0 0 Hi all, When we try to access a key container, CryptAcquireContext may return NTE_BAD_KEYSET (or error # 0x80090016 or -2146893802 or "Keyset does not exist") for
Prov_rsa_full
the following two reasons: 1) key container doesn't exist. You may crypt_verifycontext repeat the call to CryptAcquireContext, but this time using CRYPT_NEWKEYSET flag to create a new key container. 2) cryptcreatehash user doesn't have permission to open the key container. If you need to find out where the key container is in order to set additional permissions, this post may help: https://support.microsoft.com/en-us/kb/238187 Key Containers: Basics. Let's imagine for a sec that we are already calling CryptAcquireContext with CRYPT_NEWKEYSETflag after the first call to CryptAcquireContext fails with error NTE_BAD_KEYSET, and this second call fails with error NTE_EXISTS (or error # 0x8009000F or -2146893809 or "Object already exists").First we try to open the container and we fail, then we try to create it and https://blogs.msdn.microsoft.com/alejacma/2008/05/27/cryptacquirecontext-fails-with-nte_bad_keyset/ it already exists. NTE_BAD_KEYSET means in this casethat the user doesn't have permissions to open the key container, and not that it doesn't exist. I hope this helps. Cheers, Alex (Alejandro Campos Magencio) Tags CryptAcquireContext CryptoAPI Comments (2) Cancel reply Name * Email * Website afrikiko2000 says: September 8, 2008 at 3:14 pm Hi, am using this function and its returning 2148073487 after the second call. am wondering what it means. thanks. Reply Isaac says: April 22, 2009 at 7:02 pm Thanks Alex, Your blog provided me invaluable info for debugging my application. Regards, Isaac Reply Follow UsPopular TagsCryptoAPI System.Security Debugging WinDbg CertEnroll P/Invoke Windows 7 RSACryptoServiceProvider VBScript Windows SDK Windows Vista Windows Server 2008 Windows XP CAPICOM Smart Card ADSI Windows Server 2003 CryptAcquireContext CNG PowerShell Archives July 2012(1) May 2012(1) April 2012(6) March 2012(2) January 2012(1) November 2011(12) September 2011(5) June 2011(1) May 2011(2) April 2011(1) All of 2012(11) All of 2011(32) All of 2010(45) All of 2009(57) All of 2008(56) All of 2007(14) Privacy & Cookies Terms of Use Trademarks © 2016 Microsoft
Many moons ago I created an encryption dll for our company website. This dll was created in VB6 and http://www.jorriss.net/2004/10/22/cryptoapi-and-the-headaches-that-it-caused/ using the CryptoAPI. OK, so I cheated a bit and used some encryption code that was created by Fredrik Qvarfort. But why reinvent the wheel? Or the CryptoAPI calls? Anyways, during a routine security patch deployment the encryption dll on one of the servers stopped working. The funny thing was it was working fine on error during the other machines. So we reinstalled the web application, uninstalled and reinstalled the COM dlls as well as some system dlls. But the dll was still not working. So I had to do what I didn't want to do, write some debug code. I cracked open VB6 and wondered where all my intellisense, formatting and inline error during cryptacquirecontext help went. But after a few minutes it all came back. Like an old glove, worn but it still fits. The problem stemmed from the CryptAcquireContext function call. The CryptAcquireContext function gets a handle to the key container (where the keys are stored). Here is the code we were using: ‘Get handle to CSP If (CryptAcquireContext(hCryptProv, KEY_CONTAINER, SERVICE_PROVIDER, PROV_RSA_FULL, CRYPT_MACHINE_KEYSET) = 0) Then If (CryptAcquireContext(hCryptProv, KEY_CONTAINER, SERVICE_PROVIDER, PROV_RSA_FULL, CRYPT_MACHINE_KEYSET + CRYPT_NEWKEYSET) = 0) Then Call Err.Raise(vbObjectError + Err.LastDllError, , "CryptAcquireContext - " & DetermineError(Err.LastDllError)) End If End If The first call to CryptAcquireContext attempts to gain access to an existing key container. The second attempts to create a new container if it cannot find the existing key container. The first call was giving me an error of -2146893802. The second call was sending an error of -2146893809. Big help. Luckily, Microsoft has a KB article on translating automation errors for VB. I was able to cross reference the error hex codes with another KB