diff --git a/apps/pkey.c b/apps/pkey.c index 3e4c09b362552e..ab0c95c2acd680 100644 --- a/apps/pkey.c +++ b/apps/pkey.c @@ -208,10 +208,6 @@ int pkey_main(int argc, char **argv) goto end; } - out = bio_open_owner(outfile, outformat, private); - if (out == NULL) - goto end; - if (pubin) pkey = load_pubkey(infile, informat, 1, passin, e, "Public Key"); else @@ -219,6 +215,10 @@ int pkey_main(int argc, char **argv) if (pkey == NULL) goto end; + out = bio_open_owner(outfile, outformat, private); + if (out == NULL) + goto end; + #ifndef OPENSSL_NO_EC if (asn1_encoding != NULL || point_format != NULL) { OSSL_PARAM params[3], *p = params;