作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要以编程方式将证书导入到 Windows 存储中。CryptUIWizImport 功能运行良好,但 Windows 要求用户创建额外的密码来保护证书。但用户可以选择不设置此密码。
是否可以避开 Windows UI 并以编程方式设置此附加密码?
最佳答案
如以下代码所示,您应该清空密码字段:
#include "stdafx.h"
#include "windows.h"
#include "Cryptuiapi.h"
#pragma comment(lib, "Cryptui.lib")
int _tmain(int argc, _TCHAR* argv[]){
CRYPTUI_WIZ_IMPORT_SRC_INFO importSrc;
memset(&importSrc, 0, sizeof(CRYPTUI_WIZ_IMPORT_SRC_INFO));
importSrc.dwSize = sizeof(CRYPTUI_WIZ_IMPORT_SRC_INFO);
importSrc.dwSubjectChoice = CRYPTUI_WIZ_IMPORT_SUBJECT_FILE;
importSrc.pwszFileName = L"C:\\PathToPFX\\cert.pfx";
importSrc.pwszPassword = L"";
importSrc.dwFlags = CRYPT_EXPORTABLE | CRYPT_USER_PROTECTED;
if (CryptUIWizImport(
CRYPTUI_WIZ_NO_UI,
NULL,
NULL,
&importSrc,
NULL
) == 0)
{
printf(“CryptUIWizImport error 0x%x\n”, GetLastError());
}
return 0;
}
关于winapi - CryptUIWiz导入和保护密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16381676/
我是一名优秀的程序员,十分优秀!