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

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

<h1>SMIME_write_CMS(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="#BUGS">BUGS</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> SMIME_write_CMS - convert CMS structure to S/MIME format.
</PRE>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/cms.h&gt;
</PRE>
<PRE> int SMIME_write_CMS(BIO *out, CMS_ContentInfo *cms, BIO *data, int flags);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>SMIME_write_CMS()</CODE> adds the appropriate MIME headers to a CMS
structure to produce an S/MIME message.

</P>
<P>
<STRONG>out</STRONG> is the BIO to write the data to. <STRONG>cms</STRONG> is the appropriate
<STRONG>CMS_ContentInfo</STRONG> structure. If streaming is enabled then the content must be supplied in the <STRONG>data</STRONG> argument. <STRONG>flags</STRONG> is an optional set of flags.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
The following flags can be passed in the <STRONG>flags</STRONG> parameter.

</P>
<P>
If <STRONG>CMS_DETACHED</STRONG> is set then cleartext signing will be used, this option only makes sense
for SignedData where <STRONG>CMS_DETACHED</STRONG> is also set when <CODE>CMS_sign()</CODE> is called.

</P>
<P>
If the <STRONG>CMS_TEXT</STRONG> flag is set MIME headers for type <STRONG>text/plain</STRONG> are added to the content, this only makes sense if <STRONG>CMS_DETACHED</STRONG> is also set.

</P>
<P>
If the <STRONG>CMS_STREAM</STRONG> flag is set streaming is performed. This flag should only be set if <STRONG>CMS_STREAM</STRONG> was also set in the previous call to a CMS_ContentInfo creation function.

</P>
<P>
If cleartext signing is being used and <STRONG>CMS_STREAM</STRONG> not set then the data must be read twice: once to compute the signature in
<CODE>CMS_sign()</CODE> and once to output the S/MIME message.

</P>
<P>
If streaming is performed the content is output in BER format using
indefinite length constructed encoding except in the case of signed data
with detached content where the content is absent and DER format is used.

</P>
<P>
<HR>
<H1><A NAME="BUGS">BUGS</A></H1>
<P>
<CODE>SMIME_write_CMS()</CODE> always base64 encodes CMS structures, there
should be an option to disable this.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>SMIME_write_CMS()</CODE> returns 1 for success or 0 for failure.

</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_verify.html#">CMS_verify(3)</A>, <A HREF="../crypto/CMS_encrypt.html#">CMS_encrypt(3)</A>

<A HREF="../crypto/CMS_decrypt.html#">CMS_decrypt(3)</A>



</P>
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
<P>
<CODE>SMIME_write_CMS()</CODE> was added to OpenSSL 0.9.8

</P>
:}

