summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorDr. David von Oheimb <dev@ddvo.net>2024-09-27 07:58:33 +0200
committerTomas Mraz <tomas@openssl.org>2024-10-04 12:09:33 +0200
commitd5c4a8aecca691506824326f43be06ad36216c11 (patch)
treecd6f2180660c9aebdcabeed22bdf7d7edf68d46e /apps
parentAPPS/ocsp: fix case where reqin and outfile are the same (diff)
downloadopenssl-d5c4a8aecca691506824326f43be06ad36216c11.tar.xz
openssl-d5c4a8aecca691506824326f43be06ad36216c11.zip
APPS/pkcs8: fix case where infile and outfile are the same
Reviewed-by: Viktor Dukhovni <viktor@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/25552)
Diffstat (limited to 'apps')
-rw-r--r--apps/pkcs8.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/apps/pkcs8.c b/apps/pkcs8.c
index 7b5e79966b..22978afb90 100644
--- a/apps/pkcs8.c
+++ b/apps/pkcs8.c
@@ -227,9 +227,6 @@ int pkcs8_main(int argc, char **argv)
informat == FORMAT_UNDEF ? FORMAT_PEM : informat);
if (in == NULL)
goto end;
- out = bio_open_owner(outfile, outformat, private);
- if (out == NULL)
- goto end;
if (topk8) {
pkey = load_key(infile, informat, 1, passin, e, "key");
@@ -240,6 +237,8 @@ int pkcs8_main(int argc, char **argv)
ERR_print_errors(bio_err);
goto end;
}
+ if ((out = bio_open_owner(outfile, outformat, private)) == NULL)
+ goto end;
if (nocrypt) {
assert(private);
if (outformat == FORMAT_PEM) {
@@ -361,6 +360,9 @@ int pkcs8_main(int argc, char **argv)
}
assert(private);
+ out = bio_open_owner(outfile, outformat, private);
+ if (out == NULL)
+ goto end;
if (outformat == FORMAT_PEM) {
if (traditional)
PEM_write_bio_PrivateKey_traditional(out, pkey, NULL, NULL, 0,