
#use wml::openssl-macros area=docs page=CMS_add0_cert

<title>Documents, CMS_add0_cert(3)</title>

<h1>CMS_add0_cert(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#NOTES">NOTES</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
	<LI><A HREF="#HISTORY">HISTORY</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<PRE> CMS_add0_cert, CMS_add1_cert, CMS_get1_certs, CMS_add0_crl, CMS_get1_crls, - CMS certificate and CRL utility functions
</PRE>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/cms.h&gt;
</PRE>
<PRE> int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);
 int CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);
 STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);
</PRE>
<PRE> int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);
 int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);
 STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>CMS_add0_cert()</CODE> and <CODE>CMS_add1_cert()</CODE> add
certificate <STRONG>cert</STRONG> to <STRONG>cms</STRONG>. must be of type signed data or enveloped data. 

</P>
<P>
<CODE>CMS_get1_certs()</CODE> returns all certificates in <STRONG>cms</STRONG>.

</P>
<P>
<CODE>CMS_add0_crl()</CODE> and <CODE>CMS_add1_crl()</CODE> add CRL <STRONG>crl</STRONG> to <STRONG>cms</STRONG>. <CODE>CMS_get1_crls()</CODE> returns any CRLs in <STRONG>cms</STRONG>.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
The CMS_ContentInfo structure <STRONG>cms</STRONG> must be of type signed data or enveloped data or an error will be returned.

</P>
<P>
For signed data certificates and CRLs are added to the <STRONG>certificates</STRONG> and
<STRONG>crls</STRONG> fields of SignedData structure. For enveloped data they are added to
<STRONG>OriginatorInfo</STRONG>.

</P>
<P>
As the <STRONG>0</STRONG> implies <CODE>CMS_add0_cert()</CODE> adds <STRONG>cert</STRONG> internally to <STRONG>cms</STRONG> and it must not be freed up after the call as opposed to
<CODE>CMS_add1_cert()</CODE> where <STRONG>cert</STRONG>
must be freed up.

</P>
<P>
The same certificate or CRL must not be added to the same cms structure
more than once.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>CMS_add0_cert(),</CODE> <CODE>CMS_add1_cert()</CODE> and
<CODE>CMS_add0_crl()</CODE> and <CODE>CMS_add1_crl()</CODE> return 1 for
success and 0 for failure. 

</P>
<P>
<CODE>CMS_get1_certs()</CODE> and <CODE>CMS_get1_crls()</CODE> return the
STACK of certificates or CRLs or NULL if there are none or an error occurs.
The only error which will occur in practice is if the <STRONG>cms</STRONG> type is invalid.

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../crypto/ERR_get_error.html#">ERR_get_error(3)</A>,
<A HREF="../crypto/CMS_sign.html#">CMS_sign(3)</A>,
<A HREF="../crypto/CMS_encrypt.html#">CMS_encrypt(3)</A>



</P>
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
<P>
<CODE>CMS_add0_cert(),</CODE> <CODE>CMS_add1_cert(),</CODE>
<CODE>CMS_get1_certs(),</CODE> <CODE>CMS_add0_crl()</CODE> and
<CODE>CMS_get1_crls()</CODE> were all first added to OpenSSL 0.9.8

</P>
:}


