@@ -2513,7 +2513,7 @@ int wolfSSH_CTX_UsePrivateKey_fromStore(WOLFSSH_CTX* ctx,
25132513 heap = ctx -> heap ;
25142514
25152515 /* Open the certificate store */
2516- hStore = CertOpenStore (CERT_STORE_PROV_SYSTEM_W , 0 , NULL ,
2516+ hStore = CertOpenStore (CERT_STORE_PROV_SYSTEM_W , 0 , ( HCRYPTPROV_LEGACY ) 0 ,
25172517 dwFlags | CERT_STORE_OPEN_EXISTING_FLAG , storeName );
25182518 if (hStore == NULL ) {
25192519 DWORD dwErr = GetLastError ();
@@ -2639,7 +2639,7 @@ int wolfSSH_CTX_UsePrivateKey_fromStore(WOLFSSH_CTX* ctx,
26392639 /* Set up the private key structure */
26402640 ctx -> privateKey [keyIdx ].publicKeyFmt = keyId ;
26412641 ctx -> privateKey [keyIdx ].useCertStore = 1 ;
2642- ctx -> privateKey [keyIdx ].certStoreContext = pCertContext ;
2642+ ctx -> privateKey [keyIdx ].certStoreContext = ( void * ) pCertContext ;
26432643
26442644 /* Store the store name and subject name */
26452645 {
@@ -2657,8 +2657,8 @@ int wolfSSH_CTX_UsePrivateKey_fromStore(WOLFSSH_CTX* ctx,
26572657 return WS_MEMORY_E ;
26582658 }
26592659
2660- wcscpy (storeNameCopy , storeName );
2661- wcscpy (subjectNameCopy , subjectName );
2660+ WMEMCPY (storeNameCopy , storeName , storeNameLen * sizeof ( wchar_t ) );
2661+ WMEMCPY (subjectNameCopy , subjectName , subjectNameLen * sizeof ( wchar_t ) );
26622662 ctx -> privateKey [keyIdx ].storeName = storeNameCopy ;
26632663 ctx -> privateKey [keyIdx ].subjectName = subjectNameCopy ;
26642664 ctx -> privateKey [keyIdx ].dwFlags = dwFlags ;
@@ -2703,6 +2703,7 @@ int wolfSSH_CTX_UsePrivateKey_fromStore(WOLFSSH_CTX* ctx,
27032703 WFREE ((void * )ctx -> privateKey [keyIdx ].subjectName , heap , DYNTYPE_STRING );
27042704 WFREE (ctx -> privateKey [keyIdx ].cert , heap , DYNTYPE_CERT );
27052705 ctx -> privateKey [keyIdx ].useCertStore = 0 ;
2706+ CertFreeCertificateContext (pCertContext );
27062707 ctx -> privateKey [keyIdx ].certStoreContext = NULL ;
27072708 ctx -> privateKey [keyIdx ].storeName = NULL ;
27082709 ctx -> privateKey [keyIdx ].subjectName = NULL ;
0 commit comments