Skip to content

Commit

Permalink
apps/pkcs12: Not writing the private key file until the import passwo…
Browse files Browse the repository at this point in the history
…rd is verified

Fixes #904

CLA: trivial

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #23729)

(cherry picked from commit f546257)
  • Loading branch information
naaysayer authored and t8m committed May 14, 2024
1 parent 3ea11a8 commit 1c4bd5d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/pkcs12.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,9 +732,6 @@ int pkcs12_main(int argc, char **argv)
in = bio_open_default(infile, 'r', FORMAT_PKCS12);
if (in == NULL)
goto end;
out = bio_open_owner(outfile, FORMAT_PEM, private);
if (out == NULL)
goto end;

p12 = PKCS12_init_ex(NID_pkcs7_data, app_get0_libctx(), app_get0_propq());
if (p12 == NULL) {
Expand Down Expand Up @@ -834,6 +831,11 @@ int pkcs12_main(int argc, char **argv)

dump:
assert(private);

out = bio_open_owner(outfile, FORMAT_PEM, private);
if (out == NULL)
goto end;

if (!dump_certs_keys_p12(out, p12, cpass, -1, options, passout, enc)) {
BIO_printf(bio_err, "Error outputting keys and certificates\n");
ERR_print_errors(bio_err);
Expand Down

0 comments on commit 1c4bd5d

Please sign in to comment.