From: Dr. Stephen Henson Date: Mon, 2 Jun 2014 13:12:07 +0000 (+0100) Subject: Allow reordering of certificates when signing. X-Git-Tag: OpenSSL_1_0_2-beta2~176 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4967a832ab7e57613dc8baebd316a2542dabbddf;p=oweals%2Fopenssl.git Allow reordering of certificates when signing. Add certificates if -nocerts and -certfile specified when signing in smime application. This can be used this to specify the order certificates appear in the PKCS#7 structure: some broken applications require a certain ordering. PR#3316 (cherry picked from commit e114abee9ec084a56c1d6076ac6de8a7a3a5cf34) --- diff --git a/apps/smime.c b/apps/smime.c index d1fe32d31b..d1ee48937e 100644 --- a/apps/smime.c +++ b/apps/smime.c @@ -704,6 +704,14 @@ int MAIN(int argc, char **argv) p7 = PKCS7_sign(NULL, NULL, other, in, flags); if (!p7) goto end; + if (flags & PKCS7_NOCERTS) + { + for (i = 0; i < sk_X509_num(other); i++) + { + X509 *x = sk_X509_value(other, i); + PKCS7_add_certificate(p7, x); + } + } } else flags |= PKCS7_REUSE_DIGEST;