diff options
author | Rich Salz <rsalz@akamai.com> | 2021-02-08 14:20:01 -0500 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2021-02-12 08:34:17 +1000 |
commit | 03bbd346f4410c329d472cc043fb6c49f6688eba (patch) | |
tree | 4404d27a430f7a3c8a33ddd6d0633fb35d9a4065 /apps/pkcs12.c | |
parent | d0190e11639956677747f6bc7bb5bcd610fd8600 (diff) |
Fetch cipher after loading providers
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14135)
Diffstat (limited to 'apps/pkcs12.c')
-rw-r--r-- | apps/pkcs12.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/apps/pkcs12.c b/apps/pkcs12.c index 8cc1f8eeb5..e96f9ec4a4 100644 --- a/apps/pkcs12.c +++ b/apps/pkcs12.c @@ -145,7 +145,7 @@ const OPTIONS pkcs12_options[] = { int pkcs12_main(int argc, char **argv) { char *infile = NULL, *outfile = NULL, *keyname = NULL, *certfile = NULL; - char *untrusted = NULL; + char *untrusted = NULL, *ciphername = NULL, *enc_flag = NULL; char *passcertsarg = NULL, *passcerts = NULL; char *name = NULL, *csp_name = NULL; char pass[PASSWD_BUF_SIZE] = "", macpass[PASSWD_BUF_SIZE] = ""; @@ -164,7 +164,6 @@ int pkcs12_main(int argc, char **argv) BIO *in = NULL, *out = NULL; PKCS12 *p12 = NULL; STACK_OF(OPENSSL_STRING) *canames = NULL; - const char *enc_flag = NULL; const EVP_CIPHER *const default_enc = EVP_aes_256_cbc(); const EVP_CIPHER *enc = default_enc; OPTION_CHOICE o; @@ -220,10 +219,19 @@ int pkcs12_main(int argc, char **argv) case OPT_EXPORT: export_pkcs12 = 1; break; + case OPT_NODES: + case OPT_NOENC: + /* + * |enc_flag| stores the name of the option used so it + * can be printed if an error message is output. + */ + enc_flag = opt_flag() + 1; + enc = NULL; + ciphername = NULL; + break; case OPT_CIPHER: + ciphername = opt_unknown(); enc_flag = opt_unknown(); - if (!opt_cipher(enc_flag, &enc)) - goto opthelp; break; case OPT_ITER: if (!opt_int(opt_arg(), &iter)) @@ -246,11 +254,6 @@ int pkcs12_main(int argc, char **argv) case OPT_MACALG: macalg = opt_arg(); break; - case OPT_NODES: - case OPT_NOENC: - enc_flag = opt_flag() + 1; - enc = NULL; - break; case OPT_CERTPBE: if (!set_pbe(&cert_pbe, opt_arg())) goto opthelp; @@ -342,6 +345,10 @@ int pkcs12_main(int argc, char **argv) goto opthelp; app_RAND_load(); + if (ciphername != NULL) { + if (!opt_cipher(ciphername, &enc)) + goto opthelp; + } if (export_pkcs12) { if ((options & INFO) != 0) WARN_EXPORT("info"); |