19. januar 2004 - 16:38Der er
4 kommentarer og 1 løsning
Importere certifikat.
Hej, hvordan importere jeg et certifikat via C++? Jeg kan åbne system store, og finde alle certifikater. Nu er jeg dog i tvivl om hvordan jeg tilføjer/importere et certifikat. Skal jeg først bruge:
CertCreateCertificateContext() Og i giver fald, hvad så bagefter?
Mød TrackMan og Veo på Computerworld Cloud & AI Festival og hør, hvordan tech ændrer måden, vi træner og udvikler talent – fra skolebold til The Masters.
//-------------------------------------------------------------------- // Open a system certificate store. hSysStore = CertOpenStore( CERT_STORE_PROV_SYSTEM, // The store provider type 0, // The encoding type is not needed NULL, // Use the default HCRYPTPROV CERT_SYSTEM_STORE_LOCAL_MACHINE, // Set the store location in a registry location L"CA" // The store name as a Unicode string );
if(!hSysStore) { return false; }
pCertContext = CertCreateCertificateContext( MY_ENCODING_TYPE , // encoding type //PKCS_7_ASN_ENCODING, pDecodeCert, // encoded data from // the certificate retrieved dwCertSize); // length of the encoded data if(!pCertContext) error();
bErr = CertAddCertificateContextToStore( hSysStore, pCertContext, CERT_STORE_ADD_NEW, NULL); if (!bErr) error(); else { printf("A new certificate has been added.\n"); }
//-------------------------------------------------------------------- //Close Cert Store. if (hSysStore) { bErr = CertCloseStore(hSysStore, CERT_CLOSE_STORE_CHECK_FLAG); if (!bErr) return false; } return true; }
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.