Error During Cryptacquirecontext 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
Cryptacquirecontexta
Developers Sale Sale Find a store Gift cards Products Software & services Windows Office Free downloads & security Internet cryptacquirecontext failed windows 7 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
here for a quick overview of the site Help Center Detailed answers to any questions you might have
Prov_rsa_full
Meta Discuss the workings and policies of this site About Us crypt_verifycontext Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with
Cryptcreatehash
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just https://support.microsoft.com/en-us/kb/238187 like you, helping each other. Join them; it only takes a minute: Sign up CryptoAPI AcquireContext fails to retrieve key container up vote 2 down vote favorite I am porting an old vb6 application to .net and I am having an issue since yesterday afternoon with some CryptoAPI calls. In particular I can't retrieve a key http://stackoverflow.com/questions/15945218/cryptoapi-acquirecontext-fails-to-retrieve-key-container container which is already defined. I use the CryptAcquireContext() function. I use some test code where I create the container. Then If I go to C:\Users...\Roaming\Microsoft\Crypto\RSA\Machine Keys\ I can see a file created with my defined container name inside so I assume it's created successfully. A subsequent call to try creating the same container verifies that assumption because I get the win32 error that the keyset is already defined. Anyway on my next code call where I try to retrieve the container I already created I get the windows error that the keyset is not defined. Error : -2146893799 (80090019) The keyset is not defined. Any ideas? Here's a code example : public const uint PROV_RSA_FULL = 1; public const uint CRYPT_NEWKEYSET = 0x00000008; public const uint CRYPT_MACHINE_KEYSET = 0x00000020; const string MS_DEF_PROV = "Microsoft Base Cryptographic Provider v1.0"; [DllImport("advapi32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool CryptAcquireContext(out IntPtr phProv, string pszContainer, string pszProvider, uint dwProvType, uint dwFlags); public static void CreateContainer() { IntPtr hCr
från GoogleLogga inDolda fältSök efter grupper eller meddelanden
//-------------------------------------------------------------------- // Ïðèìåð êîäà, èñïîëüçóþùåãî CryptAcquireContext. //-------------------------------------------------------------------- #define MY_ENCODING_TYPE (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING) static HCRYPTPROV hCryptProv = 0; static HCRYPTKEY hKey = 0; static void CleanUp(void); static void HandleError(char *s); int main(int argc, char *argv[]) { // Îáúÿâëåíèå è èíèöèàëèçàöèÿ ïåðåìåííûõ. BYTE pbData[MAX_CONTAINER_NAME_LEN+1]; DWORD cbData; BOOL bSilent = FALSE; // Ôëàã ðåæèìà áåç îêîí if (argc > 1 && strcmp(argv[1], "-silent") == 0) bSilent = TRUE; printf("Mode: %s\n", bSilent ? "SILENT" : "NORMAL"); // Ïîëó÷åíèå äåñêðèïòîðà êðèïòîïðîâàéäåðà. if(!CryptAcquireContext( &hCryptProv, CONTAINER, NULL, PROV_GOST_2001_DH, 0)) { if(!(GetLastError() == 0x80090016 )) { SetLastError(0x80090016); HandleError("A general error occurred running CryptAcquireContext"); } printf(" The default key container does not exist.\n"); printf(" Create a default container and generate keys \n"); printf(" Using the code in \n"); printf(" Example C Program: Creating a Key Container and Generating Keys \n"); printf(" Before running this program. \n"); CleanUp(); exit(0); } printf("CryptAcquireContext succeeded.\n"); // ×òåíèå èìåíè CSP. cbData = MAX_CONTAINER_NAME_LEN; if(!CryptGetProvParam( hCryptProv, PP_NAME, NULL, &cbData, 0)) { HandleError("Error reading CSP name. \n"); } if(cbData > MAX_CONTAINER_NAME_LEN) HandleError("CSP name length is too long"); pbData[MAX_CONTAINER_NAME_LEN] = 0; if(!CryptGetProvParam( hCryptProv, PP_NAME, pbData, &cbData, 0)) { HandleError("Error reading CSP name. \n"); } printf("CryptGetProvParam succeeded.\n"); printf("Provider name: %s\n", pbData); // ×òåíèå èìåíè êëþ÷åâîãî êîíòåéíåðà. cbData = MAX_CONTAINER_NAME_LEN; if(!CryptGetProvParam( hCryptProv, PP_CONTAINER, pbData, &cbData, 0)) { HandleError("Error reading key container name. \n"); } if(cbData > MAX_CONTAINER_NAME_LEN) HandleError("Container name length is too long"); if(!CryptGetProvParam( hCryptProv, PP_CONTAINER, pbData, &cbData, 0)) { HandleError("Error reading key container name. \n"); } printf("CryptGetProvParam succeeded. \n"); printf("Key Container name: %s\n", pbData); // Âûïîëíåíèå êðèïòîãðàôè÷åñêèõ îïåðàöèé. // Óâåëè÷åíèå ñ÷åò÷èêà ññûëîê íà êðèïòîïðîâàéäåð. Êîãäà ñ÷åò÷èê ññûëîê íà // êðèïòîïðîâàéäåð ñòàíîâèòñÿ áîëüøå 1, CryptReleaseContext óìåíüøàåò // ñ÷åò÷èê ññûëîê, íî íå îñâîáîæäàåò êðèïòîïðîâàéäåð.