Update from stable branch.
[openssl.git] / engines / e_capi.c
index 76b05b76abe0aadada1ecd1aa19ab2087394571f..be01278ad4643980e951e9531227405b7292c5a4 100644 (file)
@@ -1618,6 +1618,11 @@ static int client_cert_select(ENGINE *e, SSL *ssl, STACK_OF(X509) *certs)
 
 #include <cryptuiapi.h>
 
+#define dlg_title L"OpenSSL Application SSL Client Certificate Selection"
+#define dlg_prompt L"Select a certificate to use for authentication"
+#define dlg_columns     CRYPTUI_SELECT_LOCATION_COLUMN \
+                       |CRYPTUI_SELECT_INTENDEDUSE_COLUMN
+
 static int client_cert_select(ENGINE *e, SSL *ssl, STACK_OF(X509) *certs)
        {
        X509 *x;
@@ -1625,6 +1630,7 @@ static int client_cert_select(ENGINE *e, SSL *ssl, STACK_OF(X509) *certs)
        PCCERT_CONTEXT cert;
        CAPI_CTX *ctx;
        CAPI_KEY *key;
+       HWND hwnd;
        int i, idx = -1;
        ctx = ENGINE_get_ex_data(e, capi_idx);
        /* Create an in memory store of certificates */
@@ -1651,9 +1657,13 @@ static int client_cert_select(ENGINE *e, SSL *ssl, STACK_OF(X509) *certs)
                        }
 
                }
+       hwnd = GetActiveWindow();
+       if (!hwnd)
+               hwnd = GetConsoleWindow();
        /* Call dialog to select one */
-       cert = CryptUIDlgSelectCertificateFromStore(dstore, NULL,NULL, NULL,
-                                                       0, 0, NULL);
+       cert = CryptUIDlgSelectCertificateFromStore(dstore, hwnd,
+                                                       dlg_title, dlg_prompt,
+                                                       dlg_columns, 0, NULL);
 
        /* Find matching cert from list */
        if (cert)