gpt4 book ai didi

winapi - CryptUIWiz导入和保护密码

转载 作者:行者123 更新时间:2023-12-02 04:33:51 26 4
gpt4 key购买 nike

我需要以编程方式将证书导入到 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com