X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fcms.c;h=6d227acabe82957b71b2488cf845538705bd3201;hb=5dffc13f55234f0e30914d8d7d1727afbb8fc675;hp=70bf45f3f4602e88f10c69b2c45bd7c58dcbc524;hpb=339654e1631f5e0707db0ad3cbad8b4db02cf4f9;p=oweals%2Fopenssl.git diff --git a/apps/cms.c b/apps/cms.c index 70bf45f3f4..6d227acabe 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -107,6 +107,7 @@ int MAIN(int argc, char **argv) char *signerfile = NULL, *recipfile = NULL; STACK *sksigners = NULL, *skkeys = NULL; char *certfile = NULL, *keyfile = NULL, *contfile=NULL; + char *certsoutfile = NULL; const EVP_CIPHER *cipher = NULL; CMS_ContentInfo *cms = NULL, *rcms = NULL; X509_STORE *store = NULL; @@ -396,6 +397,12 @@ int MAIN(int argc, char **argv) goto argerr; recipfile = *++args; } + else if (!strcmp (*args, "-certsout")) + { + if (!args[1]) + goto argerr; + certsoutfile = *++args; + } else if (!strcmp (*args, "-md")) { if (!args[1]) @@ -601,6 +608,7 @@ int MAIN(int argc, char **argv) BIO_printf (bio_err, "-noattr don't include any signed attributes\n"); BIO_printf (bio_err, "-binary don't translate message to text\n"); BIO_printf (bio_err, "-certfile file other certificates file\n"); + BIO_printf (bio_err, "-certsout file certificate output file\n"); BIO_printf (bio_err, "-signer file signer certificate file\n"); BIO_printf (bio_err, "-recip file recipient certificate file for decryption\n"); BIO_printf (bio_err, "-skeyid use subject key identifier\n"); @@ -796,6 +804,20 @@ int MAIN(int argc, char **argv) goto end; } } + if (certsoutfile) + { + STACK_OF(X509) *allcerts; + allcerts = CMS_get1_certs(cms); + if (!save_certs(certsoutfile, allcerts)) + { + BIO_printf(bio_err, + "Error writing certs to %s\n", + certsoutfile); + ret = 5; + goto end; + } + sk_X509_pop_free(allcerts, X509_free); + } } if (rctfile) @@ -1027,7 +1049,7 @@ int MAIN(int argc, char **argv) } else if (operation == SMIME_UNCOMPRESS) { - if (!CMS_uncompress(cms, out, indata, flags)) + if (!CMS_uncompress(cms, indata, out, flags)) goto end; } else if (operation == SMIME_DIGEST_VERIFY)