Juan Lang : cryptui: Disable the PFX export format in the export wizard unless the source has a private key .

Alexandre Julliard julliard at winehq.org
Mon Jan 26 10:13:37 CST 2009


Module: wine
Branch: master
Commit: 7f9c8fa92fd3e4eb5c0ec40c68223337ef6c148f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7f9c8fa92fd3e4eb5c0ec40c68223337ef6c148f

Author: Juan Lang <juan.lang at gmail.com>
Date:   Fri Jan 23 09:04:14 2009 -0800

cryptui: Disable the PFX export format in the export wizard unless the source has a private key.

---

 dlls/cryptui/cryptui_En.rc |    2 +-
 dlls/cryptui/main.c        |   13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/dlls/cryptui/cryptui_En.rc b/dlls/cryptui/cryptui_En.rc
index f876c58..41f671d 100644
--- a/dlls/cryptui/cryptui_En.rc
+++ b/dlls/cryptui/cryptui_En.rc
@@ -380,7 +380,7 @@ BEGIN
   CHECKBOX "&Include all certificates in the certification path if possible",
     IDC_EXPORT_CMS_INCLUDE_CHAIN, 44,57,200,8, BS_AUTOCHECKBOX|WS_TABSTOP|WS_DISABLED
   AUTORADIOBUTTON "&Personal Information Exchange/PKCS #12 (.pfx)",
-    IDC_EXPORT_FORMAT_PFX, 31,72,200,12, BS_AUTORADIOBUTTON
+    IDC_EXPORT_FORMAT_PFX, 31,72,200,12, BS_AUTORADIOBUTTON|WS_DISABLED
   CHECKBOX "Incl&ude all certificates in the certification path if possible",
     IDC_EXPORT_PFX_INCLUDE_CHAIN, 44,87,200,8, BS_AUTOCHECKBOX|WS_TABSTOP|WS_DISABLED
   CHECKBOX "&Enable strong encryption",
diff --git a/dlls/cryptui/main.c b/dlls/cryptui/main.c
index 8542828..2eef5dc 100644
--- a/dlls/cryptui/main.c
+++ b/dlls/cryptui/main.c
@@ -5567,6 +5567,19 @@ static LRESULT CALLBACK export_file_dlg_proc(HWND hwnd, UINT msg, WPARAM wp,
 
         data = (struct ExportWizData *)page->lParam;
         SetWindowLongPtrW(hwnd, DWLP_USER, (LPARAM)data);
+        if (data->pExportInfo->dwSubjectChoice ==
+         CRYPTUI_WIZ_EXPORT_CERT_CONTEXT)
+        {
+            DWORD size;
+
+            /* If there's a CRYPT_KEY_PROV_INFO set for this cert, assume the
+             * cert has a private key.
+             */
+            if (CertGetCertificateContextProperty(
+             data->pExportInfo->u.pCertContext, CERT_KEY_PROV_INFO_PROP_ID,
+             NULL, &size))
+                EnableWindow(GetDlgItem(hwnd, IDC_EXPORT_FORMAT_PFX), TRUE);
+        }
         break;
     }
     case WM_NOTIFY:




More information about the wine-cvs mailing list