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

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

<h1>SMIME_read_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_read_CMS - parse S/MIME message.
</PRE>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/cms.h&gt;
</PRE>
<PRE> CMS_ContentInfo *SMIME_read_CMS(BIO *in, BIO **bcont);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>SMIME_read_CMS()</CODE> parses a message in S/MIME format.

</P>
<P>
<STRONG>in</STRONG> is a BIO to read the message from.

</P>
<P>
If cleartext signing is used then the content is saved in a memory bio
which is written to <STRONG>*bcont</STRONG>, otherwise <STRONG>*bcont</STRONG> is set to NULL.

</P>
<P>
The parsed CMS_ContentInfo structure is returned or NULL if an error
occurred.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
If <STRONG>*bcont</STRONG> is not NULL then the message is clear text signed. <STRONG>*bcont</STRONG> can then be passed to <CODE>CMS_verify()</CODE> with the <STRONG>CMS_DETACHED</STRONG> flag set.

</P>
<P>
Otherwise the type of the returned structure can be determined using
<CODE>CMS_get0_type().</CODE>

</P>
<P>
To support future functionality if <STRONG>bcont</STRONG> is not NULL <STRONG>*bcont</STRONG> should be initialized to NULL. For example:

</P>
<PRE> BIO *cont = NULL;
 CMS_ContentInfo *cms;
</PRE>
<PRE> cms = SMIME_read_CMS(in, &amp;cont);
</PRE>
<P>
<HR>
<H1><A NAME="BUGS">BUGS</A></H1>
<P>
The MIME parser used by <CODE>SMIME_read_CMS()</CODE> is somewhat
primitive. While it will handle most S/MIME messages more complex compound
formats may not work.

</P>
<P>
The parser assumes that the CMS_ContentInfo structure is always base64
encoded and will not handle the case where it is in binary format or uses
quoted printable format.

</P>
<P>
The use of a memory BIO to hold the signed content limits the size of
message which can be processed due to memory restraints: a streaming single
pass option should be available.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>SMIME_read_CMS()</CODE> returns a valid <STRONG>CMS_ContentInfo</STRONG> structure or <STRONG>NULL</STRONG>
if an error occurred. The error can be obtained from
<CODE>ERR_get_error(3).</CODE>

</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>, <EM>CMS_type(3)</EM>

<A HREF="../crypto/SMIME_read_CMS.html#">SMIME_read_CMS(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_read_CMS()</CODE> was added to OpenSSL 0.9.8

</P>
:}

