summaryrefslogtreecommitdiffstats
path: root/apps/pkcs8.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-03-21 18:08:57 +0100
committerRichard Levitte <levitte@openssl.org>2016-03-31 13:32:01 +0200
commit923b1857decf4440b13b82f2aa7cf1189327d1a3 (patch)
tree6b6a6387610cdad0b7a1bdbb0b23da12ac80bc94 /apps/pkcs8.c
parent4de9913b8c2a11f17258a2ad5e357046fd221360 (diff)
Fix "no-ui" configuration
Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'apps/pkcs8.c')
-rw-r--r--apps/pkcs8.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/apps/pkcs8.c b/apps/pkcs8.c
index 8a4d5423d1..15b8e6a084 100644
--- a/apps/pkcs8.c
+++ b/apps/pkcs8.c
@@ -111,7 +111,10 @@ int pkcs8_main(int argc, char **argv)
const EVP_CIPHER *cipher = NULL;
char *infile = NULL, *outfile = NULL;
char *passinarg = NULL, *passoutarg = NULL, *prog;
- char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL;
+#ifndef OPENSSL_NO_UI
+ char pass[50];
+#endif
+ char *passin = NULL, *passout = NULL, *p8pass = NULL;
OPTION_CHOICE o;
int nocrypt = 0, ret = 1, iter = PKCS12_DEFAULT_ITER;
int informat = FORMAT_PEM, outformat = FORMAT_PEM, topk8 = 0, pbe_nid = -1;
@@ -272,13 +275,18 @@ int pkcs8_main(int argc, char **argv)
}
if (passout)
p8pass = passout;
- else {
+ else if (1) {
+#ifndef OPENSSL_NO_UI
p8pass = pass;
if (EVP_read_pw_string
(pass, sizeof pass, "Enter Encryption Password:", 1)) {
X509_ALGOR_free(pbe);
goto end;
}
+ } else {
+#endif
+ BIO_printf(bio_err, "Password required\n");
+ goto end;
}
app_RAND_load_file(NULL, 0);
p8 = PKCS8_set0_pbe(p8pass, strlen(p8pass), p8inf, pbe);
@@ -330,9 +338,14 @@ int pkcs8_main(int argc, char **argv)
}
if (passin)
p8pass = passin;
- else {
+ else if (1) {
+#ifndef OPENSSL_NO_UI
p8pass = pass;
EVP_read_pw_string(pass, sizeof pass, "Enter Password:", 0);
+ } else {
+#endif
+ BIO_printf(bio_err, "Password required\n");
+ goto end;
}
p8inf = PKCS8_decrypt(p8, p8pass, strlen(p8pass));
}