summaryrefslogtreecommitdiffstats
path: root/crypto/pem
diff options
context:
space:
mode:
authorMat <mberchtold@gmail.com>2016-05-09 21:36:39 +0200
committerRich Salz <rsalz@openssl.org>2016-05-31 17:39:00 -0400
commitb01e1644d7f7a0d750340540385e93db7d180fd6 (patch)
treea7825e76c7f2125418f2ff144d62240133ed31f6 /crypto/pem
parent80c630f6574a33b1c633815a174110d10ec37c60 (diff)
Fix: PEM_read_bio_PrivateKey with no-ui / no-stdio
If openssl is compiled with no-ui or no-stdio, then PEM_read_bio_PrivateKey fails if a password but no callback is provided. The reason is that the premature return in the PEM_def_callback implementation when OPENSSL_NO_STDIO or OPENSSL_NO_UI is defined, comes too early. This patch moves the ifdef block to the correct place. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/pem')
-rw-r--r--crypto/pem/pem_lib.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c
index 42b46dc4d5..0f281629a0 100644
--- a/crypto/pem/pem_lib.c
+++ b/crypto/pem/pem_lib.c
@@ -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:";