Juan Lang : cryptui: Use helper function for importing certificates.
Alexandre Julliard
julliard at winehq.org
Tue Dec 23 13:41:10 CST 2008
Module: wine
Branch: master
Commit: 8216c07a967e589e71ecc3cc6029dd0cccd6ab9a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8216c07a967e589e71ecc3cc6029dd0cccd6ab9a
Author: Juan Lang <juan.lang at gmail.com>
Date: Mon Dec 22 10:56:35 2008 -0800
cryptui: Use helper function for importing certificates.
---
dlls/cryptui/main.c | 53 ++++++++++++++++++++++++++++----------------------
1 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/dlls/cryptui/main.c b/dlls/cryptui/main.c
index 442cd19..8a1b149 100644
--- a/dlls/cryptui/main.c
+++ b/dlls/cryptui/main.c
@@ -3443,13 +3443,36 @@ static HCERTSTORE choose_store_for_cert(PCCERT_CONTEXT cert)
CERT_SYSTEM_STORE_CURRENT_USER, storeName);
}
+static BOOL import_cert(PCCERT_CONTEXT cert, HCERTSTORE hDestCertStore)
+{
+ HCERTSTORE store;
+ BOOL ret;
+
+ if (!cert)
+ {
+ SetLastError(E_INVALIDARG);
+ return FALSE;
+ }
+ if (hDestCertStore) store = hDestCertStore;
+ else
+ {
+ if (!(store = choose_store_for_cert(cert)))
+ {
+ WARN("unable to open certificate store\n");
+ return FALSE;
+ }
+ }
+ ret = CertAddCertificateContextToStore(store, cert,
+ CERT_STORE_ADD_REPLACE_EXISTING, NULL);
+ if (!hDestCertStore) CertCloseStore(store, 0);
+ return ret;
+}
+
BOOL WINAPI CryptUIWizImport(DWORD dwFlags, HWND hwndParent, LPCWSTR pwszWizardTitle,
PCCRYPTUI_WIZ_IMPORT_SRC_INFO pImportSrc, HCERTSTORE hDestCertStore)
{
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);
@@ -3472,35 +3495,19 @@ BOOL WINAPI CryptUIWizImport(DWORD dwFlags, HWND hwndParent, LPCWSTR pwszWizardT
return FALSE;
}
else
- freeCert = TRUE;
- break;
- case CRYPTUI_WIZ_IMPORT_SUBJECT_CERT_CONTEXT:
- cert = pImportSrc->u.pCertContext;
- if (!cert)
{
- SetLastError(E_INVALIDARG);
- return FALSE;
+ ret = import_cert(cert, hDestCertStore);
+ CertFreeCertificateContext(cert);
}
break;
+ case CRYPTUI_WIZ_IMPORT_SUBJECT_CERT_CONTEXT:
+ ret = import_cert(pImportSrc->u.pCertContext, hDestCertStore);
+ break;
default:
FIXME("source type not implemented: %u\n", pImportSrc->dwSubjectChoice);
SetLastError(E_INVALIDARG);
return FALSE;
}
- if (hDestCertStore) store = hDestCertStore;
- else
- {
- if (!(store = choose_store_for_cert(cert)))
- {
- WARN("unable to open certificate store\n");
- CertFreeCertificateContext(cert);
- return FALSE;
- }
- }
- ret = CertAddCertificateContextToStore(store, cert, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
- if (!hDestCertStore) CertCloseStore(store, 0);
- if (freeCert)
- CertFreeCertificateContext(cert);
return ret;
}
More information about the wine-cvs
mailing list