Make certs argument work in CMS_sign() add test case.
PR:1664
This commit is contained in:
parent
0f401ff08b
commit
e6ef05d5f3
@ -457,23 +457,23 @@ CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
|
|||||||
{
|
{
|
||||||
CMS_ContentInfo *cms;
|
CMS_ContentInfo *cms;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
cms = CMS_ContentInfo_new();
|
cms = CMS_ContentInfo_new();
|
||||||
if (!cms)
|
if (!cms || !CMS_SignedData_init(cms))
|
||||||
goto merr;
|
goto merr;
|
||||||
|
|
||||||
if (pkey && !CMS_add1_signer(cms, signcert, pkey, NULL, flags))
|
if (pkey && !CMS_add1_signer(cms, signcert, pkey, NULL, flags))
|
||||||
{
|
{
|
||||||
CMSerr(CMS_F_CMS_SIGN, CMS_R_ADD_SIGNER_ERROR);
|
CMSerr(CMS_F_CMS_SIGN, CMS_R_ADD_SIGNER_ERROR);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < sk_X509_num(certs); i++)
|
for (i = 0; i < sk_X509_num(certs); i++)
|
||||||
{
|
{
|
||||||
X509 *x = sk_X509_value(certs, i);
|
X509 *x = sk_X509_value(certs, i);
|
||||||
if (!CMS_add1_cert(cms, x))
|
if (!CMS_add1_cert(cms, x))
|
||||||
goto merr;
|
goto merr;
|
||||||
}
|
}
|
||||||
/* If no signer or certs initialize signedData */
|
|
||||||
if (!pkey && !i && !CMS_SignedData_init(cms))
|
|
||||||
goto merr;
|
|
||||||
|
|
||||||
if(!(flags & CMS_DETACHED))
|
if(!(flags & CMS_DETACHED))
|
||||||
CMS_set_detached(cms, 0);
|
CMS_set_detached(cms, 0);
|
||||||
|
@ -81,6 +81,7 @@ my @smime_pkcs7_tests = (
|
|||||||
[
|
[
|
||||||
"signed content DER format, RSA key",
|
"signed content DER format, RSA key",
|
||||||
"-sign -in smcont.txt -outform DER -nodetach"
|
"-sign -in smcont.txt -outform DER -nodetach"
|
||||||
|
. " -certfile $smdir/smroot.pem"
|
||||||
. " -signer $smdir/smrsa1.pem -out test.cms",
|
. " -signer $smdir/smrsa1.pem -out test.cms",
|
||||||
"-verify -in test.cms -inform DER "
|
"-verify -in test.cms -inform DER "
|
||||||
. " -CAfile $smdir/smroot.pem -out smtst.txt"
|
. " -CAfile $smdir/smroot.pem -out smtst.txt"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user