Commit 3f705af9 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

cryptui: Support importing certificate contexts.

parent dd815611
......@@ -146,12 +146,11 @@ BOOL WINAPI CryptUIWizImport(DWORD dwFlags, HWND hwndParent, LPCWSTR pwszWizardT
BOOL ret;
HCERTSTORE store;
const CERT_CONTEXT *cert;
BOOL freeCert = FALSE;
TRACE("(0x%08x, %p, %s, %p, %p)\n", dwFlags, hwndParent, debugstr_w(pwszWizardTitle),
pImportSrc, hDestCertStore);
FIXME("only certificate files are supported\n");
if (!(dwFlags & CRYPTUI_WIZ_NO_UI)) FIXME("UI not implemented\n");
if (!pImportSrc ||
......@@ -161,14 +160,28 @@ BOOL WINAPI CryptUIWizImport(DWORD dwFlags, HWND hwndParent, LPCWSTR pwszWizardT
return FALSE;
}
if (pImportSrc->dwSubjectChoice != CRYPTUI_WIZ_IMPORT_SUBJECT_FILE)
switch (pImportSrc->dwSubjectChoice)
{
case CRYPTUI_WIZ_IMPORT_SUBJECT_FILE:
if (!(cert = make_cert_from_file(pImportSrc->pwszFileName)))
{
WARN("unable to create certificate context\n");
return FALSE;
}
else
freeCert = TRUE;
break;
case CRYPTUI_WIZ_IMPORT_SUBJECT_CERT_CONTEXT:
cert = pImportSrc->pCertContext;
if (!cert)
{
SetLastError(E_INVALIDARG);
return FALSE;
}
break;
default:
FIXME("source type not implemented: %u\n", pImportSrc->dwSubjectChoice);
return FALSE;
}
if (!(cert = make_cert_from_file(pImportSrc->pwszFileName)))
{
WARN("unable to create certificate context\n");
SetLastError(E_INVALIDARG);
return FALSE;
}
if (hDestCertStore) store = hDestCertStore;
......@@ -185,6 +198,7 @@ BOOL WINAPI CryptUIWizImport(DWORD dwFlags, HWND hwndParent, LPCWSTR pwszWizardT
ret = CertAddCertificateContextToStore(store, cert, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
if (!hDestCertStore) CertCloseStore(store, 0);
CertFreeCertificateContext(cert);
if (freeCert)
CertFreeCertificateContext(cert);
return ret;
}
......@@ -202,19 +202,16 @@ static void test_crypt_ui_wiz_import(void)
info.dwSize = sizeof(info);
SetLastError(0xdeadbeef);
ret = pCryptUIWizImport(CRYPTUI_WIZ_NO_UI, 0, NULL, &info, NULL);
todo_wine
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
info.dwSubjectChoice = CRYPTUI_WIZ_IMPORT_SUBJECT_CERT_CONTEXT;
SetLastError(0xdeadbeef);
ret = pCryptUIWizImport(CRYPTUI_WIZ_NO_UI, 0, NULL, &info, NULL);
todo_wine
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
ret = pCryptUIWizImport(CRYPTUI_WIZ_NO_UI | CRYPTUI_WIZ_IMPORT_ALLOW_CERT,
0, NULL, &info, NULL);
todo_wine
ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08x\n", GetLastError());
/* Imports the following cert--self-signed, with no basic constraints set--
......@@ -287,10 +284,9 @@ static void test_crypt_ui_wiz_import(void)
}
ret = pCryptUIWizImport(CRYPTUI_WIZ_NO_UI |
CRYPTUI_WIZ_IMPORT_NO_CHANGE_DEST_STORE, 0, NULL, &info, store);
todo_wine
ok(ret, "CryptUIWizImport failed: %08x\n", GetLastError());
find_and_delete_cert_in_store(store, "memory", info.u.pCertContext,
"iTunesCert3", TRUE);
"iTunesCert3", FALSE);
CertFreeCertificateContext(info.u.pCertContext);
CertCloseStore(store, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment