Reg Certificate to IE
来源:互联网 发布:局域网通话软件 编辑:程序博客网 时间:2024/05/17 04:31
char *CSPName = "Your USBKEY CSP";
int CSP_ImportUserCert(
unsigned char *containerName,
unsigned long containerNameLen,
unsigned long keyUsage,
unsigned char *certificate,
unsigned long certificateLen)
{
HCRYPTPROV hProv = 0;
HCRYPTKEY hUserKey = NULL;
BYTE ErrInfo[1024];
BYTE pbContiner[1024];
DWORD dwFlag;
int rv;
PCCERT_CONTEXT pCertContext = NULL;
HCERTSTORE hCertStore;
memcpy(pbContiner,containerName,containerNameLen);
pbContiner[containerNameLen] = '/0'
dwFlag = 0;
CRYPT_KEY_PROV_INFO KeyProvInfo;
hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0,
CERT_STORE_OPEN_EXISTING_FLAG |
CERT_SYSTEM_STORE_CURRENT_USER, L"MY");
if(hCertStore == NULL)
{
sprintf((char *)ErrInfo,"### CertOpenSystemStore Error.ErrCode:0x%x",GetLastError());
DEBUGMSG(ErrInfo);
CryptReleaseContext(hProv,0);
return -1;
}
DEBUGMSG("*** CertOpenSystemStore OK.");
if(pCertContext = CertCreateCertificateContext(
X509_ASN_ENCODING , // The encoding type
certificate, // The encoded data from
// the certificate retrieved
certificateLen)) // The length of the encoded data
{
printf("A new certificate as been created./n");
}
else
{
printf("A new certificate could not be created.");
return -1;
}
ZeroMemory((PVOID)&KeyProvInfo, sizeof(CRYPT_KEY_PROV_INFO));
CString strcontainerName;
CString strCSPName;
strcontainerName = containerName;
strCSPName = CSPName;
KeyProvInfo.pwszContainerName = strcontainerName.AllocSysString();
KeyProvInfo.pwszProvName = strCSPName.AllocSysString();
KeyProvInfo.dwProvType = PROV_RSA_FULL;
KeyProvInfo.dwFlags = 0;
KeyProvInfo.dwKeySpec = keyUsage;
if(!CertSetCertificateContextProperty(pCertContext,
CERT_KEY_PROV_INFO_PROP_ID,
0,
(const void *) &KeyProvInfo))
{
sprintf((char *)ErrInfo,"### CertSetCertificateContextProperty Error.ErrCode:0x%x",GetLastError());
DEBUGMSG(ErrInfo);
}
if(CertAddCertificateContextToStore(hCertStore,pCertContext,CERT_STORE_ADD_REPLACE_EXISTING,0))
{
printf("A new certificate as been add to strore./n");
}
else
{
sprintf((char *)ErrInfo,"### CertAddCertificateContextToStore Error.ErrCode:0x%x",GetLastError());
DEBUGMSG(ErrInfo);
}
CertFreeCertificateContext(pCertContext);
DEBUGMSG("*** CSP_ImportUserCert OK.");
return 0;
}
- Reg Certificate to IE
- Failed to sync vcpu reg
- Failed to sync vcpu reg
- How to generate certificate
- 为win7添加桌面IE.reg
- Reg
- reg
- reg
- Webdriver - IE security certificate when access https
- Webdriver - IE security certificate when access https
- 另存为(恢复IE设置.reg)双击导入注册表
- Unable to find manifest signing certificate in the certificate store.
- Unable to find manifest signing certificate in the certificate store
- git SSL certificate problem: unable to get local issuer certificate
- SSL certificate problem: unable to get local issuer certificate
- SSL certificate problem: unable to get local issuer certificate
- SSL certificate problem: unable to get local issuer certificate 解决方法
- Git: SSL certificate problem: unable to get local issuer certificate
- EAP和EAPOL资料
- Platform Builder: Find the Source of a Data Abort; an Example
- 动态表单数据库设计
- hook监视窗口
- linux typedef的四个用途和两个陷阱
- Reg Certificate to IE
- jmx是什么?
- 中断解析
- 太恐怖了!什么都能查!!
- 由viewWillAppear没有被调用见控制器结构设计上的误区
- Redhat常用操作记录笔记
- 自写易飞ERP上线方案:环境设定
- linux下传输文件
- 金山词霸 & IE9取词兼容性补丁包下载(来自官方)