diff options
author | Richard Levitte <levitte@openssl.org> | 2015-09-04 12:49:06 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2015-09-06 01:35:54 +0200 |
commit | bdd58d98467e9f0f6635c1628e1eae304383afb1 (patch) | |
tree | 1927fc4a65f8fd8b5705c5c5e0278beabf2c2b28 /apps/pkcs12.c | |
parent | d303b9d85e1888494785f87ebd9bd233e63564a9 (diff) |
Change the way apps open their input and output files
The different apps had the liberty to decide whether they would open their
input and output files in binary mode or not, which could be confusing if
two different apps were handling the same type of file in different ways.
The solution is to centralise the decision of low level file organisation,
and that the apps would use a selection of formats to state the intent of
the file.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'apps/pkcs12.c')
-rw-r--r-- | apps/pkcs12.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/apps/pkcs12.c b/apps/pkcs12.c index 5b14dd5320..2e74cd4bae 100644 --- a/apps/pkcs12.c +++ b/apps/pkcs12.c @@ -353,13 +353,6 @@ int pkcs12_main(int argc, char **argv) app_RAND_load_files(inrand)); } - in = bio_open_default(infile, "rb"); - if (in == NULL) - goto end; - out = bio_open_owner(outfile, "wb", private); - if (out == NULL) - goto end; - if (twopass) { if (EVP_read_pw_string (macpass, sizeof macpass, "Enter MAC Password:", export_cert)) { @@ -501,6 +494,11 @@ int pkcs12_main(int argc, char **argv) PKCS12_set_mac(p12, mpass, -1, NULL, 0, maciter, macmd); assert(private); + + out = bio_open_owner(outfile, FORMAT_PKCS12, private); + if (out == NULL) + goto end; + i2d_PKCS12_bio(out, p12); ret = 0; @@ -515,6 +513,13 @@ 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; + if ((p12 = d2i_PKCS12_bio(in, NULL)) == NULL) { ERR_print_errors(bio_err); goto end; |