X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=apps%2Fsmime.c;h=ef0e4774644542ffca00bd19158697b7bd69db62;hp=42451728db540c335681271e5c7776b6ec1da31e;hb=ca80756c70ad8f05ccd5d37c01c38641f7da3d3d;hpb=6d498d478e8606c1c71ab9a88a72403f3a32dd44 diff --git a/apps/smime.c b/apps/smime.c index 42451728db..ef0e477464 100644 --- a/apps/smime.c +++ b/apps/smime.c @@ -109,6 +109,12 @@ int MAIN(int argc, char **argv) args = argv + 1; ret = 1; + apps_startup(); + + if (bio_err == NULL) + if ((bio_err = BIO_new(BIO_s_file())) != NULL) + BIO_set_fp(bio_err, stderr, BIO_NOCLOSE|BIO_FP_TEXT); + if (!load_config(bio_err, NULL)) goto end; @@ -422,7 +428,7 @@ int MAIN(int argc, char **argv) } else keyfile = NULL; if(keyfile) { - key = load_key(bio_err, keyfile, keyform, passin, e, + key = load_key(bio_err, keyfile, keyform, 0, passin, e, "signing key file"); if (!key) { goto end; @@ -465,7 +471,10 @@ int MAIN(int argc, char **argv) p7 = PKCS7_encrypt(encerts, in, cipher, flags); } else if(operation == SMIME_SIGN) { p7 = PKCS7_sign(signer, key, other, in, flags); - BIO_reset(in); + if (BIO_reset(in) != 0 && (flags & PKCS7_DETACHED)) { + BIO_printf(bio_err, "Can't rewind input file\n"); + goto end; + } } else { if(informat == FORMAT_SMIME) p7 = SMIME_read_PKCS7(in, &indata);