本文整理汇总了C++中CertEnumCertificatesInStore函数的典型用法代码示例。如果您正苦于以下问题:C++ CertEnumCertificatesInStore函数的具体用法?C++ CertEnumCertificatesInStore怎么用?C++ CertEnumCertificatesInStore使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CertEnumCertificatesInStore函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: doit
void doit(void)
{
HCERTSTORE hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER , L"ROOT");
assert(hStore != NULL);
HCERTSTORE hSystemStore = CertOpenSystemStore(0, "ROOT");
assert(hSystemStore != NULL);
PCCERT_CONTEXT prevCtx = NULL;
PCCERT_CONTEXT ctx = NULL;
PCCERT_CONTEXT sysPrevCtx = NULL;
PCCERT_CONTEXT sysCtx = NULL;
while (1)
{
ctx = CertEnumCertificatesInStore(hStore, prevCtx);
sysCtx = CertEnumCertificatesInStore(hSystemStore, sysPrevCtx);
if (ctx == NULL || sysCtx == NULL)
break;
if (CertCompareIntegerBlob(&ctx->pCertInfo->SerialNumber,
&sysCtx->pCertInfo->SerialNumber) != TRUE)
assert(0);
prevCtx = ctx;
sysPrevCtx = sysCtx;
}
assert(ctx == NULL && sysCtx == NULL);
CertCloseStore(hStore, 0);
CertCloseStore(hSystemStore, 0);
}
开发者ID:gnutls,项目名称:gnutls,代码行数:30,代码来源:win-certopenstore.c
示例2: _tmain
// usage: DumpCertsFromSst <output directory> <SST file 1> ... <SST file n>
int _tmain(int argc, _TCHAR* argv[])
{
SECURITY_ATTRIBUTES sa;
memset(&sa, 0, sizeof(SECURITY_ATTRIBUTES));
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = FALSE;
if(argc < 2)
{
std::cout << "At least one argument must be provided: sstFile1 sstFile2 ... sstFileN etc" << std::endl;
return 0;
}
for(int ii = 1; ii < argc; ++ii)
{
HANDLE hFile = NULL;
HCERTSTORE hFileStore = NULL;
LPCWSTR pszFileName = argv[ii];
//Open file
hFile = CreateFile(pszFileName, GENERIC_READ, 0, &sa, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(INVALID_HANDLE_VALUE == hFile)
{
std::wcout << "Failed to open file: " << pszFileName << std::endl;
continue;
}
else
{
std::wcout << "Processing file: " << pszFileName << std::endl;
}
//open certificate store
hFileStore = CertOpenStore(CERT_STORE_PROV_FILE, 0, NULL, CERT_STORE_READONLY_FLAG, hFile);
if(NULL == hFileStore)
{
CloseHandle(hFile);
continue;
}
int count = 0;
PCCERT_CONTEXT pPrevCertContext = NULL;
pPrevCertContext = CertEnumCertificatesInStore(hFileStore, pPrevCertContext);
while(NULL != pPrevCertContext)
{
if(WriteToFileWithHashAsFilename(pPrevCertContext)) ++count;
pPrevCertContext = CertEnumCertificatesInStore(hFileStore, pPrevCertContext);
}
std::wcout << "Wrote " << count << " certificates" << std::endl;
CloseHandle(hFile);
CertCloseStore(hFileStore, 0);
}
return 1;
}
开发者ID:untangle,项目名称:ngfw_src,代码行数:59,代码来源:sstexport.cpp
示例3: isUntrustedRootCertInStore
//TODO: Will be removed
static int isUntrustedRootCertInStore(const KSI_PKITruststore *pki, const PCCERT_CHAIN_CONTEXT pChainContext){
DWORD j=0;
PCCERT_CONTEXT pUntrustedRootCert = NULL;
PCCERT_CONTEXT certFound = NULL;
if (pChainContext == NULL) return false;
if (pChainContext->cChain > 1) return false;
for (j=0; j<pChainContext->rgpChain[0]->cElement; j++){
PCERT_CHAIN_ELEMENT element = pChainContext->rgpChain[0]->rgpElement[j];
if (element->TrustStatus.dwErrorStatus&CERT_TRUST_IS_UNTRUSTED_ROOT && element->TrustStatus.dwInfoStatus&CERT_TRUST_IS_SELF_SIGNED){
pUntrustedRootCert = element->pCertContext;
while ((certFound = CertEnumCertificatesInStore(pki->collectionStore, certFound)) != NULL){
if (certFound->cbCertEncoded == pUntrustedRootCert->cbCertEncoded){
if (memcmp(certFound->pbCertEncoded, pUntrustedRootCert->pbCertEncoded, certFound->cbCertEncoded)==0){
CertFreeCertificateContext(certFound);
return true;
}
}
}
}
}
return false;
}
开发者ID:khushil,项目名称:libksi,代码行数:28,代码来源:pkitruststore_cryptoapi.c
示例4: printCertsInStore
/*TODO: for debugging*/
static void printCertsInStore(HCERTSTORE certStore){
PCCERT_CONTEXT certFound = NULL;
DWORD i =0;
if (certStore == NULL){
printf("Cert store is nullptr\n");
return;
}
do{
certFound = CertEnumCertificatesInStore(certStore,certFound);
if (certFound != NULL){
printf(" >>%2i)",i++);
printCertInfo(certFound);
}
else{
printf(" >>No more certs to print.\n");
}
}
while (certFound != NULL);
}
开发者ID:khushil,项目名称:libksi,代码行数:27,代码来源:pkitruststore_cryptoapi.c
示例5: sqAddPfxCertToStore
/* sqAddPfxCertToStore: Adds a PFX certificate to MY certificate store.
Arguments:
pfxData - the contents of the PFX certificate file
pfxLen - the length of the PFX certificate file
passData - the utf8 encoded password for the file
passLen - the size of the password
Returns: 1 on success, 0 on failure
*/
static sqInt sqAddPfxCertToStore(char *pfxData, sqInt pfxLen, char *passData, sqInt passLen) {
PCCERT_CONTEXT pContext;
HCERTSTORE pfxStore, myStore;
CRYPT_DATA_BLOB blob;
WCHAR widePass[4096];
/* Verify that this is a PFX file */
blob.cbData = pfxLen;
blob.pbData = pfxData;
if(!PFXIsPFXBlob(&blob)) return 0; /* Not a PFX blob */
/* Verify that the password is all right */
widePass[0] = 0;
if(passLen > 0) {
DWORD wideLen = MultiByteToWideChar(CP_UTF8, 0, passData, passLen, widePass, 4095);
widePass[wideLen] = 0;
}
if(!PFXVerifyPassword(&blob, widePass, 0)) return 0; /* Invalid password */
/* Import the PFX blob into a temporary store */
pfxStore = PFXImportCertStore(&blob, widePass, 0);
if(!pfxStore) return 0;
/* And copy the certificates to MY store */
myStore = CertOpenSystemStore(0, "MY");
pContext = NULL;
while(pContext = CertEnumCertificatesInStore(pfxStore, pContext)) {
CertAddCertificateContextToStore(myStore, pContext, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
}
CertCloseStore(myStore, 0);
CertCloseStore(pfxStore, 0);
return 1;
}
开发者ID:JeanBaptisteArnaud,项目名称:RaspLocalDebug,代码行数:41,代码来源:sqWin32SSL.c
示例6: loadPrivCertStore
PCCERT_CONTEXT SslCredential::findCertificate(const std::string& name)
{
loadPrivCertStore();
if (loadError.pending())
return NULL;
// search for the certificate by Friendly Name
PCCERT_CONTEXT tmpctx = NULL;
while (tmpctx = CertEnumCertificatesInStore(certStore, tmpctx)) {
DWORD len = CertGetNameString(tmpctx, CERT_NAME_FRIENDLY_DISPLAY_TYPE,
0, NULL, NULL, 0);
if (len == 1)
continue;
std::vector<char> ctxname(len);
CertGetNameString(tmpctx, CERT_NAME_FRIENDLY_DISPLAY_TYPE,
0, NULL, &ctxname[0], len);
bool found = !name.compare(&ctxname[0]);
if (found)
break;
}
// verify whether some certificate has been found
if (tmpctx == NULL) {
loadError.set(Msg() << "Client SSL/TLS certificate not found in the certificate store for name " << name,
"client certificate not found");
}
return tmpctx;
}
开发者ID:gregerts,项目名称:debian-qpid-cpp,代码行数:28,代码来源:SslCredential.cpp
示例7: capi_find_cert
static PCCERT_CONTEXT capi_find_cert(CAPI_CTX *ctx, const char *id, HCERTSTORE hstore)
{
PCCERT_CONTEXT cert = NULL;
char *fname = NULL;
int match;
switch(ctx->lookup_method)
{
case CAPI_LU_SUBSTR:
return CertFindCertificateInStore(hstore,
X509_ASN_ENCODING, 0,
CERT_FIND_SUBJECT_STR_A, id, NULL);
case CAPI_LU_FNAME:
for(;;)
{
cert = CertEnumCertificatesInStore(hstore, cert);
if (!cert)
return NULL;
fname = capi_cert_get_fname(ctx, cert);
if (fname)
{
if (strcmp(fname, id))
match = 0;
else
match = 1;
OPENSSL_free(fname);
if (match)
return cert;
}
}
default:
return NULL;
}
}
开发者ID:Groestlcoin,项目名称:foreign,代码行数:33,代码来源:e_capi.c
示例8: defined
void MumbleSSL::addSystemCA() {
#if QT_VERSION < 0x040700 && !defined(NO_SYSTEM_CA_OVERRIDE)
#if defined(Q_OS_WIN)
QStringList qsl;
qsl << QLatin1String("Ca");
qsl << QLatin1String("Root");
qsl << QLatin1String("AuthRoot");
foreach(const QString &store, qsl) {
HCERTSTORE hCertStore;
PCCERT_CONTEXT pCertContext = NULL;
bool found = false;
hCertStore = CertOpenSystemStore(NULL, store.utf16());
if (! hCertStore) {
qWarning("SSL: Failed to open CA store %s", qPrintable(store));
continue;
}
while (pCertContext = CertEnumCertificatesInStore(hCertStore, pCertContext)) {
QByteArray qba(reinterpret_cast<const char *>(pCertContext->pbCertEncoded), pCertContext->cbCertEncoded);
QList<QSslCertificate> ql = QSslCertificate::fromData(qba, QSsl::Pem);
ql += QSslCertificate::fromData(qba, QSsl::Der);
if (! ql.isEmpty()) {
found = true;
QSslSocket::addDefaultCaCertificates(ql);
}
}
if (found)
qWarning("SSL: Added CA certificates from system store '%s'", qPrintable(store));
CertCloseStore(hCertStore, 0);
}
开发者ID:rivenx,项目名称:mumble,代码行数:34,代码来源:SSL.cpp
示例9: gnutls_system_key_iter_get_info
/**
* gnutls_system_key_iter_get_info:
* @iter: an iterator of the system keys (must be set to %NULL initially)
* @cert_type: A value of gnutls_certificate_type_t which indicates the type of certificate to look for
* @cert_url: The certificate URL of the pair (may be %NULL)
* @key_url: The key URL of the pair (may be %NULL)
* @label: The friendly name (if any) of the pair (may be %NULL)
* @der: if non-NULL the DER data of the certificate
* @flags: should be zero
*
* This function will return on each call a certificate
* and key pair URLs, as well as a label associated with them,
* and the DER-encoded certificate. When the iteration is complete it will
* return %GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE.
*
* Typically @cert_type should be %GNUTLS_CRT_X509.
*
* All values set are allocated and must be cleared using gnutls_free(),
*
* Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a
* negative error value.
*
* Since: 3.4.0
**/
int
gnutls_system_key_iter_get_info(gnutls_system_key_iter_t * iter,
unsigned cert_type,
char **cert_url,
char **key_url,
char **label,
gnutls_datum_t * der, unsigned int flags)
{
if (ncrypt_init == 0)
return gnutls_assert_val(GNUTLS_E_UNIMPLEMENTED_FEATURE);
if (cert_type != GNUTLS_CRT_X509)
return gnutls_assert_val(GNUTLS_E_UNIMPLEMENTED_FEATURE);
if (*iter == NULL) {
*iter = gnutls_calloc(1, sizeof(struct system_key_iter_st));
if (*iter == NULL)
return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
(*iter)->store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, L"MY");
if ((*iter)->store == NULL) {
gnutls_free(*iter);
*iter = NULL;
return
gnutls_assert_val
(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE);
}
(*iter)->cert =
CertEnumCertificatesInStore((*iter)->store, NULL);
return get_win_urls((*iter)->cert, cert_url, key_url, label,
der);
} else {
if ((*iter)->cert == NULL)
return
gnutls_assert_val
(GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE);
(*iter)->cert =
CertEnumCertificatesInStore((*iter)->store, (*iter)->cert);
return get_win_urls((*iter)->cert, cert_url, key_url, label,
der);
}
}
开发者ID:gnutls,项目名称:gnutls,代码行数:69,代码来源:keys-win.c
示例10: TestCryptoCertEnumCertificatesInStore
int TestCryptoCertEnumCertificatesInStore(int argc, char* argv[])
{
int index;
DWORD status;
LPTSTR pszNameString;
HCERTSTORE hCertStore = NULL;
PCCERT_CONTEXT pCertContext = NULL;
/**
* System Store Locations:
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa388136/
*/
/**
* Requires elevated rights:
* hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, (HCRYPTPROV_LEGACY) NULL, CERT_SYSTEM_STORE_LOCAL_MACHINE, _T("Remote Desktop"));
*/
hCertStore = CertOpenSystemStore((HCRYPTPROV_LEGACY) NULL, _T("MY"));
// hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, (HCRYPTPROV_LEGACY) NULL, CERT_SYSTEM_STORE_CURRENT_USER, _T("MY"));
if (!hCertStore)
{
printf("Failed to open system store\n");
return -1;
}
index = 0;
while ((pCertContext = CertEnumCertificatesInStore(hCertStore, pCertContext)))
{
status = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, NULL, 0);
pszNameString = (LPTSTR) malloc(status * sizeof(TCHAR));
if (!pszNameString)
{
printf("Unable to allocate memory\n");
return -1;
}
status = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, pszNameString, status);
_tprintf(_T("Certificate #%d: %s\n"), index++, pszNameString);
#ifdef WITH_CRYPTUI
CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, pCertContext, NULL, NULL, 0, NULL);
#endif
}
if (!CertCloseStore(hCertStore, 0))
{
printf("Failed to close system store\n");
return -1;
}
return 0;
}
开发者ID:BUGgs,项目名称:FreeRDP,代码行数:57,代码来源:TestCryptoCertEnumCertificatesInStore.c
示例11: while
QList<QSslCertificate> CertStore::list() const
{
QList<QSslCertificate> list;
PCCERT_CONTEXT c = 0;
while( (c = CertEnumCertificatesInStore( d->s, c )) )
list << QSslCertificate( QByteArray( (char*)c->pbCertEncoded, c->cbCertEncoded ), QSsl::Der );
CertFreeCertificateContext( c );
return list;
}
开发者ID:martinpaljak,项目名称:qesteidutil,代码行数:9,代码来源:CertStore.cpp
示例12: check_and_store_certs
static void check_and_store_certs(HCERTSTORE from, HCERTSTORE to)
{
DWORD root_count = 0;
CERT_CHAIN_ENGINE_CONFIG chainEngineConfig =
{ sizeof(chainEngineConfig), 0 };
HCERTCHAINENGINE engine;
TRACE("\n");
CertDuplicateStore(to);
engine = CRYPT_CreateChainEngine(to, &chainEngineConfig);
if (engine)
{
PCCERT_CONTEXT cert = NULL;
do {
cert = CertEnumCertificatesInStore(from, cert);
if (cert)
{
CERT_CHAIN_PARA chainPara = { sizeof(chainPara), { 0 } };
PCCERT_CHAIN_CONTEXT chain;
BOOL ret = CertGetCertificateChain(engine, cert, NULL, from,
&chainPara, 0, NULL, &chain);
if (!ret)
TRACE("rejecting %s: %s\n", get_cert_common_name(cert),
"chain creation failed");
else
{
/* The only allowed error is CERT_TRUST_IS_UNTRUSTED_ROOT */
if (chain->TrustStatus.dwErrorStatus &
~CERT_TRUST_IS_UNTRUSTED_ROOT)
TRACE("rejecting %s: %s\n", get_cert_common_name(cert),
trust_status_to_str(chain->TrustStatus.dwErrorStatus &
~CERT_TRUST_IS_UNTRUSTED_ROOT));
else
{
DWORD i, j;
for (i = 0; i < chain->cChain; i++)
for (j = 0; j < chain->rgpChain[i]->cElement; j++)
if (CertAddCertificateContextToStore(to,
chain->rgpChain[i]->rgpElement[j]->pCertContext,
CERT_STORE_ADD_NEW, NULL))
root_count++;
}
CertFreeCertificateChain(chain);
}
}
} while (cert);
CertFreeCertificateChainEngine(engine);
}
TRACE("Added %d root certificates\n", root_count);
}
开发者ID:WASSUM,项目名称:longene_travel,代码行数:54,代码来源:rootstore.c
示例13: importCertStoreToX509_STORE
// This imports the certificates in a given Windows certificate store into an
// X509_STORE for
// openssl to use during certificate validation.
static int importCertStoreToX509_STORE(
LPWSTR storeName, DWORD storeLocation, X509_STORE* verifyStore, char* err, size_t err_len) {
int status = 1;
X509* x509Cert = NULL;
HCERTSTORE systemStore =
CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, (HCRYPTPROV)NULL, storeLocation | CERT_STORE_READONLY_FLAG, storeName);
if (systemStore == NULL) {
formatError(GetLastError(),"error opening system CA store",err,err_len);
status = 0;
goto CLEANUP;
}
PCCERT_CONTEXT certCtx = NULL;
while ((certCtx = CertEnumCertificatesInStore(systemStore, certCtx)) != NULL) {
const uint8_t * certBytes = (const uint8_t *)(certCtx->pbCertEncoded);
x509Cert = d2i_X509(NULL, &certBytes, certCtx->cbCertEncoded);
if (x509Cert == NULL) {
// 120 from the SSL documentation for ERR_error_string
static const size_t msglen = 120;
char msg[msglen];
ERR_error_string_n(ERR_get_error(), msg, msglen);
snprintf(
err, err_len, "Error parsing X509 object from Windows certificate store %s", msg);
status = 0;
goto CLEANUP;
}
if (1 != X509_STORE_add_cert(verifyStore, x509Cert)) {
int store_error_status = checkX509_STORE_error(err, err_len);
if (!store_error_status) {
status = 0;
goto CLEANUP;
}
}
}
DWORD lastError = GetLastError();
if (lastError != CRYPT_E_NOT_FOUND) {
formatError(lastError,"Error enumerating certificates",err,err_len);
status = 0;
goto CLEANUP;
}
CLEANUP:
if (systemStore != NULL) {
CertCloseStore(systemStore, 0);
}
if (x509Cert != NULL) {
X509_free(x509Cert);
}
return status;
}
开发者ID:ShaneHarvey,项目名称:mongo,代码行数:54,代码来源:system_certs.c
示例14: _mongoc_openssl_import_cert_store
bool
_mongoc_openssl_import_cert_store (LPWSTR store_name,
DWORD dwFlags,
X509_STORE *openssl_store)
{
PCCERT_CONTEXT cert = NULL;
HCERTSTORE cert_store;
cert_store = CertOpenStore (
CERT_STORE_PROV_SYSTEM, /* provider */
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, /* certificate encoding */
0, /* unused */
dwFlags, /* dwFlags */
store_name); /* system store name. "My" or "Root" */
if (cert_store == NULL) {
LPTSTR msg = NULL;
FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_ARGUMENT_ARRAY,
NULL,
GetLastError (),
LANG_NEUTRAL,
(LPTSTR) &msg,
0,
NULL);
MONGOC_ERROR ("Can't open CA store: 0x%.8X: '%s'", (unsigned int) GetLastError (), msg);
LocalFree (msg);
return false;
}
while ((cert = CertEnumCertificatesInStore (cert_store, cert)) != NULL) {
X509 *x509Obj = d2i_X509 (NULL,
(const unsigned char **) &cert->pbCertEncoded,
cert->cbCertEncoded);
if (x509Obj == NULL) {
MONGOC_WARNING (
"Error parsing X509 object from Windows certificate store");
continue;
}
X509_STORE_add_cert (openssl_store, x509Obj);
X509_free (x509Obj);
}
CertCloseStore (cert_store, 0);
return true;
}
开发者ID:cran,项目名称:mongolite,代码行数:49,代码来源:mongoc-openssl.c
示例15: CertOpenStore
void CEstEIDCertificate::readFromCertContext() {
LOG_LOCATION;
PCCERT_CONTEXT pCertContext = NULL;
HCERTSTORE hCertStore = NULL;
CRYPTUI_SELECTCERTIFICATE_STRUCT sel = {sizeof(sel)};
int counter = 0;
hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL, CERT_SYSTEM_STORE_CURRENT_USER | CERT_STORE_READONLY_FLAG, L"MY");
if(!hCertStore){
throw CryptoException();
}
sel.pvCallbackData = &counter;
sel.pFilterCallback = filter_proc;
sel.rghDisplayStores = &hCertStore;
sel.cDisplayStores = 1;
#ifdef _SEB_BUILD
EstEID_log("SEB build");
PCCERT_CONTEXT pCertContextForEnumeration = NULL;
int certificatesCount = 0;
while(pCertContextForEnumeration = CertEnumCertificatesInStore(hCertStore, pCertContextForEnumeration)) {
if(isValidForSigning(pCertContextForEnumeration)) {
certificatesCount++;
pCertContext = pCertContextForEnumeration;
}
}
EstEID_log("Certificates count %i", certificatesCount);
if(certificatesCount != 1) {
pCertContext = CryptUIDlgSelectCertificate(&sel);
}
#else
pCertContext = CryptUIDlgSelectCertificate(&sel);
#endif
if(!pCertContext) {
EstEID_log("User didn't select sertificate");
throw CryptoException(ESTEID_USER_CANCEL);
}
loadCertContexts(pCertContext);
if(pCertContext){
CertFreeCertificateContext(pCertContext);
}
if(hCertStore) {
CertCloseStore(hCertStore, CERT_CLOSE_STORE_FORCE_FLAG);
}
}
开发者ID:rainviigipuu,项目名称:browser-token-signing,代码行数:48,代码来源:EstEIDCertificate.cpp
示例16: test_remote_cert
static void test_remote_cert(PCCERT_CONTEXT remote_cert)
{
PCCERT_CONTEXT iter = NULL;
BOOL incl_remote = FALSE;
unsigned cert_cnt = 0;
ok(remote_cert->hCertStore != NULL, "hCertStore == NULL\n");
while((iter = CertEnumCertificatesInStore(remote_cert->hCertStore, iter))) {
if(iter == remote_cert)
incl_remote = TRUE;
cert_cnt++;
}
ok(cert_cnt == 2 || cert_cnt == 3, "cert_cnt = %u\n", cert_cnt);
ok(incl_remote, "context does not contain cert itself\n");
}
开发者ID:bdidemus,项目名称:wine,代码行数:17,代码来源:schannel.c
示例17: capi_list_certs
int capi_list_certs(CAPI_CTX *ctx, BIO *out, char *id)
{
char *storename;
int idx;
int ret = 1;
HCERTSTORE hstore;
PCCERT_CONTEXT cert = NULL;
storename = ctx->storename;
if (!storename)
storename = "MY";
CAPI_trace(ctx, "Listing certs for store %s\n", storename);
hstore = capi_open_store(ctx, storename);
if (!hstore)
return 0;
if (id)
{
cert = capi_find_cert(ctx, id, hstore);
if (!cert)
{
ret = 0;
goto err;
}
capi_dump_cert(ctx, out, cert);
CertFreeCertificateContext(cert);
}
else
{
for(idx = 0;;idx++)
{
LPWSTR fname = NULL;
cert = CertEnumCertificatesInStore(hstore, cert);
if (!cert)
break;
BIO_printf(out, "Certificate %d\n", idx);
capi_dump_cert(ctx, out, cert);
}
}
err:
CertCloseStore(hstore, 0);
return ret;
}
开发者ID:Groestlcoin,项目名称:foreign,代码行数:43,代码来源:e_capi.c
示例18: open_cert_store
std::vector<X509_DN> Certificate_Store_Windows::all_subjects() const
{
std::vector<X509_DN> subject_dns;
for(const auto store_name : cert_store_names)
{
Handle_Guard<HCERTSTORE> windows_cert_store = open_cert_store(store_name);
Handle_Guard<PCCERT_CONTEXT> cert_context = nullptr;
// Handle_Guard::assign exchanges the underlying pointer. No RAII is needed here, because the Windows API takes care of
// freeing the previous context.
while(cert_context.assign(CertEnumCertificatesInStore(windows_cert_store.get(), cert_context.get())))
{
X509_Certificate cert(cert_context->pbCertEncoded, cert_context->cbCertEncoded);
subject_dns.push_back(cert.subject_dn());
}
}
return subject_dns;
}
开发者ID:randombit,项目名称:botan,代码行数:19,代码来源:certstor_windows.cpp
示例19: cexport
static void cexport(HCERTSTORE ca, FILE *fp)
{
PCCERT_CONTEXT cert = NULL;
const uint8_t *cp;
char buf[80];
while ((cert = CertEnumCertificatesInStore(ca, cert)) != NULL) {
fprintf(fp, "-----BEGIN CERTIFICATE-----\n");
size_t total = cert->cbCertEncoded;
size_t count;
cp = (const uint8_t *)cert->pbCertEncoded;
while(total) {
count = String::b64encode(buf, cp, total, 64);
if(count)
fprintf(fp, "%s\n", buf);
total -= count;
cp += count;
}
fprintf(fp, "-----END CERTIFICATE-----\n");
}
}
开发者ID:oudream,项目名称:ucommon,代码行数:21,代码来源:common.cpp
示例20: DigiCrypt_SelectCertsFromKeyContainer
static void DigiCrypt_SelectCertsFromKeyContainer(HCRYPTPROV hProv, char *psContainerName)
{
PCCERT_CONTEXT pCertContext = NULL;
HCERTSTORE hStore;
BOOL fRelease = FALSE;
char sContainer[dNAME_ITEM_LEN+1];
if (memcmp(psContainerName,"AUT",3) == 0)
{
LOG("Find1 Ignore AUT cert");
return;
}
hStore = DigiCrypt_OpenStore();
if (hStore != NULL)
{
while (TRUE)
{
pCertContext = CertEnumCertificatesInStore(hStore,pCertContext);
if (pCertContext == NULL)
break;
else
{
if (DigiCrypt_GetContainerFromCert(pCertContext, sContainer, dNAME_ITEM_LEN) == TRUE)
{
LOG("Find1 Container %s %s",sContainer,psContainerName);
if (lstrcmp(sContainer+3,psContainerName+3) == 0)
{
LOG("Find1 Container %s accepted",sContainer);
RunDlg_AddItem(pCertContext,TRUE);
}
}
}
}
}
else
LOG("Find1 Can't open store");
if (fRelease == TRUE)
CryptReleaseContext(hProv, 0);
}
开发者ID:tixsys,项目名称:esteid,代码行数:40,代码来源:DigiCrypt.cpp
注:本文中的CertEnumCertificatesInStore函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论