Fix: PEM_read_bio_PrivateKey with no-ui / no-stdio
[openssl.git] / crypto / pem / pem_lib.c
index 42b46dc4d5f059b44116583b012f64490e7b6563..0f281629a05212c1de2da3098ba26acdb15ca939 100644 (file)
@@ -30,13 +30,6 @@ int pem_check_suffix(const char *pem_str, const char *suffix);
 
 int PEM_def_callback(char *buf, int num, int w, void *key)
 {
-#if defined(OPENSSL_NO_STDIO) || defined(OPENSSL_NO_UI)
-    /*
-     * We should not ever call the default callback routine from windows.
-     */
-    PEMerr(PEM_F_PEM_DEF_CALLBACK, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
-    return (-1);
-#else
     int i, j;
     const char *prompt;
     if (key) {
@@ -46,6 +39,13 @@ int PEM_def_callback(char *buf, int num, int w, void *key)
         return (i);
     }
 
+#if defined(OPENSSL_NO_STDIO) || defined(OPENSSL_NO_UI)
+    /*
+     * We should not ever call the default callback routine from windows.
+     */
+    PEMerr(PEM_F_PEM_DEF_CALLBACK, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+    return (-1);
+#else
     prompt = EVP_get_pw_prompt();
     if (prompt == NULL)
         prompt = "Enter PEM pass phrase:";