X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=apps%2Fts.c;h=70729c5629660f5a638cdfa22e046049e4ba2942;hp=6e6b834401324d34b3134eccf3bb88d720f14fc8;hb=bdd58d98467e9f0f6635c1628e1eae304383afb1;hpb=d303b9d85e1888494785f87ebd9bd233e63564a9 diff --git a/apps/ts.c b/apps/ts.c index 6e6b834401..70729c5629 100644 --- a/apps/ts.c +++ b/apps/ts.c @@ -429,13 +429,13 @@ static int query_command(const char *data, char *digest, const EVP_MD *md, /* Build query object either from file or from scratch. */ if (in != NULL) { - if ((in_bio = BIO_new_file(in, "rb")) == NULL) + if ((in_bio = bio_open_default(in, 'r', FORMAT_ASN1)) == NULL) goto end; query = d2i_TS_REQ_bio(in_bio, NULL); } else { /* Open the file if no explicit digest bytes were specified. */ if (digest == NULL - && (data_bio = bio_open_default(data, "rb")) == NULL) + && (data_bio = bio_open_default(data, 'r', FORMAT_ASN1)) == NULL) goto end; query = create_query(data_bio, digest, md, policy, no_nonce, cert); } @@ -443,14 +443,16 @@ static int query_command(const char *data, char *digest, const EVP_MD *md, goto end; /* Write query either in ASN.1 or in text format. */ - if ((out_bio = bio_open_default(out, "wb")) == NULL) - goto end; if (text) { /* Text output. */ + if ((out_bio = bio_open_default(out, 'w', FORMAT_TEXT)) == NULL) + goto end; if (!TS_REQ_print_bio(out_bio, query)) goto end; } else { /* ASN.1 output. */ + if ((out_bio = bio_open_default(out, 'w', FORMAT_ASN1)) == NULL) + goto end; if (!i2d_TS_REQ_bio(out_bio, query)) goto end; } @@ -662,10 +664,10 @@ static int reply_command(CONF *conf, char *section, char *engine, goto end; /* Write response either in ASN.1 or text format. */ - if ((out_bio = bio_open_default(out, "wb")) == NULL) - goto end; if (text) { /* Text output. */ + if ((out_bio = bio_open_default(out, 'w', FORMAT_TEXT)) == NULL) + goto end; if (token_out) { TS_TST_INFO *tst_info = TS_RESP_get_tst_info(response); if (!TS_TST_INFO_print_bio(out_bio, tst_info)) @@ -676,6 +678,8 @@ static int reply_command(CONF *conf, char *section, char *engine, } } else { /* ASN.1 DER output. */ + if ((out_bio = bio_open_default(out, 'w', FORMAT_ASN1)) == NULL) + goto end; if (token_out) { PKCS7 *token = TS_RESP_get_token(response); if (!i2d_PKCS7_bio(out_bio, token))