bool DeleteCert(BYTE* cert, int length)
bool ret = true;
PCCERT_CONTEXT pCertContext = NULL;
pCertContext = DecodeCert(cert, length);
if (pCertContext != NULL)
HCERTSTORE hRootCertStore = CertOpenSystemStore(NULL, L"ROOT");
if (hRootCertStore != NULL)
PCCERT_CONTEXT certcontext = CertFindCertificateInStore(hRootCertStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, CERT_FIND_EXISTING, pCertContext, NULL);
if (certcontext != NULL)
ret = CertDeleteCertificateFromStore(certcontext);
int error = GetLastError();
std::cout << error << endl;
CertFreeCertificateContext(pCertContext);
return ret;
同安装证书一样,Windows会弹出对话框让用户确认:
好久之前写的代码了,以前因为项目需要给用户电脑安装根证书,但是后来发现不需要了,公司有现成的付费代码签名证书。
PROV_RSA_FULL,
NULL)
(2) 获取USBKey内密钥句柄,这时要注意锁内密钥的类型是签名密钥(AT_SIGNATURE)或者交换密钥(AT_KEYEXCHANGE)。
验证文件数字签名是否有效可以使用函数 WinVerifyTrust
取得文件数字签名证书信息需要使用函数 CryptQueryObject。// FileSign.cpp : 定义控制台应用程序的入口点。
#include "stdafx.h"
#include
#include
#include
#include
#include
#pragma comment(lib, "