X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=apps%2Fsmime.c;h=024e83b1d2200390d4a63792a0adeccaa51fef9e;hb=6a78ae2821e89a8838714496524fd39d9d21fb1b;hp=d597ebf53479669b200004ddc3f042cfb837b5c0;hpb=d303b9d85e1888494785f87ebd9bd233e63564a9;p=openssl.git diff --git a/apps/smime.c b/apps/smime.c index d597ebf534..024e83b1d2 100644 --- a/apps/smime.c +++ b/apps/smime.c @@ -90,7 +90,8 @@ typedef enum OPTION_choice { OPT_TO, OPT_FROM, OPT_SUBJECT, OPT_SIGNER, OPT_RECIP, OPT_MD, OPT_CIPHER, OPT_INKEY, OPT_KEYFORM, OPT_CERTFILE, OPT_CAFILE, OPT_V_ENUM, - OPT_CAPATH, OPT_IN, OPT_INFORM, OPT_OUT, OPT_OUTFORM, OPT_CONTENT + OPT_CAPATH, OPT_NOCAFILE, OPT_NOCAPATH, OPT_IN, OPT_INFORM, OPT_OUT, + OPT_OUTFORM, OPT_CONTENT } OPTION_CHOICE; OPTIONS smime_options[] = { @@ -132,6 +133,10 @@ OPTIONS smime_options[] = { {"text", OPT_TEXT, '-', "Include or delete text MIME headers"}, {"CApath", OPT_CAPATH, '/', "Trusted certificates directory"}, {"CAfile", OPT_CAFILE, '<', "Trusted certificates file"}, + {"no-CAfile", OPT_NOCAFILE, '-', + "Do not load the default certificates file"}, + {"no-CApath", OPT_NOCAPATH, '-', + "Do not load certificates from the default certificates directory"}, {"resign", OPT_RESIGN, '-'}, {"nochain", OPT_NOCHAIN, '-'}, {"nosmimecap", OPT_NOSMIMECAP, '-'}, @@ -170,8 +175,8 @@ int smime_main(int argc, char **argv) NULL; char *passinarg = NULL, *passin = NULL, *to = NULL, *from = NULL, *subject = NULL; - const char *inmode = "r", *outmode = "w"; OPTION_CHOICE o; + int noCApath = 0, noCAfile = 0; int flags = PKCS7_DETACHED, operation = 0, ret = 0, need_rand = 0, indef = 0; int informat = FORMAT_SMIME, outformat = FORMAT_SMIME, keyform = @@ -349,6 +354,12 @@ int smime_main(int argc, char **argv) case OPT_CAPATH: CApath = opt_arg(); break; + case OPT_NOCAFILE: + noCAfile = 1; + break; + case OPT_NOCAPATH: + noCApath = 1; + break; case OPT_CONTENT: contfile = opt_arg(); break; @@ -411,9 +422,6 @@ int smime_main(int argc, char **argv) goto end; } - if (!app_load_modules(NULL)) - goto end; - if (need_rand) { app_RAND_load_file(NULL, (inrand != NULL)); if (inrand != NULL) @@ -426,18 +434,14 @@ int smime_main(int argc, char **argv) if (!(operation & SMIME_SIGNERS)) flags &= ~PKCS7_DETACHED; - if (operation & SMIME_OP) { - outmode = WB(outformat); - } else { + if (!(operation & SMIME_OP)) { if (flags & PKCS7_BINARY) - outmode = "wb"; + outformat = FORMAT_BINARY; } - if (operation & SMIME_IP) { - inmode = RB(informat); - } else { + if (!(operation & SMIME_IP)) { if (flags & PKCS7_BINARY) - inmode = "rb"; + informat = FORMAT_BINARY; } if (operation == SMIME_ENCRYPT) { @@ -464,8 +468,8 @@ int smime_main(int argc, char **argv) } if (certfile) { - if ((other = load_certs(certfile, FORMAT_PEM, NULL, - e, "certificate file")) == NULL) { + if (!load_certs(certfile, &other, FORMAT_PEM, NULL, e, + "certificate file")) { ERR_print_errors(bio_err); goto end; } @@ -494,7 +498,7 @@ int smime_main(int argc, char **argv) goto end; } - in = bio_open_default(infile, inmode); + in = bio_open_default(infile, 'r', informat); if (in == NULL) goto end; @@ -523,12 +527,12 @@ int smime_main(int argc, char **argv) } } - out = bio_open_default(outfile, outmode); + out = bio_open_default(outfile, 'w', outformat); if (out == NULL) goto end; if (operation == SMIME_VERIFY) { - if ((store = setup_verify(CAfile, CApath)) == NULL) + if ((store = setup_verify(CAfile, CApath, noCAfile, noCApath)) == NULL) goto end; X509_STORE_set_verify_cb(store, smime_cb); if (vpmtouched)