<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>ucommon: secure Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript"> $(document).ready(initResizable); </script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.3 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">ucommon</div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="classes.html"><span>Data Structure Index</span></a></li> <li><a href="inherits.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Data Fields</span></a></li> </ul> </div> </div> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> initNavTree('a00119.html',''); </script> <div id="doc-content"> <div class="header"> <div class="summary"> <a href="#pub-types">Public Types</a> | <a href="#pub-methods">Public Member Functions</a> | <a href="#pub-static-methods">Static Public Member Functions</a> | <a href="#pro-attribs">Protected Attributes</a> </div> <div class="headertitle"> <h1>secure Class Reference</h1> </div> </div> <div class="contents"> <!-- doxytag: class="secure" --> <p>Common secure socket support. <a href="#_details">More...</a></p> <p><code>#include <<a class="el" href="a00195_source.html">secure.h</a>></code></p> <table class="memberdecls"> <tr><td colspan="2"><h2><a name="pub-types"></a> Public Types</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab1d63dff5d26271f6161dbf5e156bcf8"></a><!-- doxytag: member="secure::bufio_t" ref="ab1d63dff5d26271f6161dbf5e156bcf8" args="" --> typedef void * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#ab1d63dff5d26271f6161dbf5e156bcf8">bufio_t</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Convenience type to represent a secure socket buf i/o stream. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae857591190cfdc648a19ff4a503f587a"></a><!-- doxytag: member="secure::client_t" ref="ae857591190cfdc648a19ff4a503f587a" args="" --> typedef <a class="el" href="a00119.html">secure</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#ae857591190cfdc648a19ff4a503f587a">client_t</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Convenience type to represent a security context. <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#ae94674293cfc03e24676257b4fe6b21f">error_t</a> { <br/>   <b>OK</b> = 0, <b>INVALID</b>, <b>MISSING_CERTIFICATE</b>, <b>MISSING_PRIVATEKEY</b>, <br/>   <b>INVALID_CERTIFICATE</b>, <b>INVALID_AUTHORITY</b>, <b>INVALID_PEERNAME</b>, <b>INVALID_CIPHER</b> <br/> }</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight"><p>Different error states of the security context. </p> <br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a229f11ced714e5b30782e9484dc2c94f"></a><!-- doxytag: member="secure::server_t" ref="a229f11ced714e5b30782e9484dc2c94f" args="" --> typedef <a class="el" href="a00119.html">secure</a> * </td><td class="memItemRight" valign="bottom"><b>server_t</b></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="adcd0244d9a8a05b793631922f90f0f17"></a><!-- doxytag: member="secure::session_t" ref="adcd0244d9a8a05b793631922f90f0f17" args="" --> typedef void * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#adcd0244d9a8a05b793631922f90f0f17">session_t</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Convenience type to represent a secure socket session. <br/></td></tr> <tr><td colspan="2"><h2><a name="pub-methods"></a> Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00119.html#ae94674293cfc03e24676257b4fe6b21f">error_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#a89f37590895e7e09e6797566037a47ed">err</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Get last error code associated with the security context. <a href="#a89f37590895e7e09e6797566037a47ed"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#a0951415d4ba8bbebdf02fc9b4a40fd0f">is</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Determine if the current security context is valid. <a href="#a0951415d4ba8bbebdf02fc9b4a40fd0f"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a4e5b8eb5d5b26e182caba0a6060a7fd7"></a><!-- doxytag: member="secure::~secure" ref="a4e5b8eb5d5b26e182caba0a6060a7fd7" args="()" --> virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#a4e5b8eb5d5b26e182caba0a6060a7fd7">~secure</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">This is derived in different back-end libraries, and will be used to clear certificate credentials. <br/></td></tr> <tr><td colspan="2"><h2><a name="pub-static-methods"></a> Static Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#a77fb8352487dd492a8f27a22a54eea52">cipher</a> (<a class="el" href="a00119.html">secure</a> *context, const char *ciphers)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Assign a non-default cipher to the context. <a href="#a77fb8352487dd492a8f27a22a54eea52"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static <a class="el" href="a00119.html">client_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#a0b24e481a4338cd021ac2bc28e3b7a8e">client</a> (const char *authority=NULL)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Create an anonymous client context with an optional authority to validate. <a href="#a0b24e481a4338cd021ac2bc28e3b7a8e"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#ada0af1c61b17a135c90564d8158d93e4">init</a> (const char *program=NULL)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Initialize secure stack for first use, and report if SSL support is compiled in. <a href="#ada0af1c61b17a135c90564d8158d93e4"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static <a class="el" href="a00119.html">server_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#a0f418366a2a74eadb48863970c7cd5c7">server</a> (const char *authority=NULL)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Create a sever context. <a href="#a0f418366a2a74eadb48863970c7cd5c7"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static <a class="el" href="a00119.html">client_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#a5d52b3f052b5b41add1577a9264b95b3">user</a> (const char *authority)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Create a peer user client context. <a href="#a5d52b3f052b5b41add1577a9264b95b3"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad42bc7078afaa09518cb054132435d91"></a><!-- doxytag: member="secure::uuid" ref="ad42bc7078afaa09518cb054132435d91" args="(void)" --> static <a class="el" href="a00150.html">String</a> </td><td class="memItemRight" valign="bottom"><b>uuid</b> (void)</td></tr> <tr><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#aa7b0ccefea2af0a588f0d26509a69e80">uuid</a> (char *<a class="el" href="a00150.html">string</a>)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Create 36 character traditional version 1 uuid. <a href="#aa7b0ccefea2af0a588f0d26509a69e80"></a><br/></td></tr> <tr><td class="memItemLeft" align="right" valign="top">static <a class="el" href="a00119.html#ae94674293cfc03e24676257b4fe6b21f">error_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#a367364c61f7f5f9765d1420b840a66fa">verify</a> (<a class="el" href="a00119.html#adcd0244d9a8a05b793631922f90f0f17">session_t</a> session, const char *peername=NULL)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Verify a certificate chain through your certificate authority. <a href="#a367364c61f7f5f9765d1420b840a66fa"></a><br/></td></tr> <tr><td colspan="2"><h2><a name="pro-attribs"></a> Protected Attributes</h2></td></tr> <tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="add599665b5de3cd1e29b2b77b4cba1fe"></a><!-- doxytag: member="secure::error" ref="add599665b5de3cd1e29b2b77b4cba1fe" args="" --> <a class="el" href="a00119.html#ae94674293cfc03e24676257b4fe6b21f">error_t</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00119.html#add599665b5de3cd1e29b2b77b4cba1fe">error</a></td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Last error flagged for this context. <br/></td></tr> </table> <hr/><a name="_details"></a><h2>Detailed Description</h2> <div class="textblock"><p>Common secure socket support. </p> <p>This offers common routines needed for secure/ssl socket support code. </p> <dl class="author"><dt><b>Author:</b></dt><dd>David Sugar <<a href="mailto:dyfet@gnutelephony.org">dyfet@gnutelephony.org</a>> </dd></dl> <dl><dt><b>Examples: </b></dt><dd> <p><a class="el" href="a00004.html#_a0">ssl.cpp</a>.</p> </dd> </dl> <p>Definition at line <a class="el" href="a00195_source.html#l00062">62</a> of file <a class="el" href="a00195_source.html">secure.h</a>.</p> </div><hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a77fb8352487dd492a8f27a22a54eea52"></a><!-- doxytag: member="secure::cipher" ref="a77fb8352487dd492a8f27a22a54eea52" args="(secure *context, const char *ciphers)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static void secure::cipher </td> <td>(</td> <td class="paramtype"><a class="el" href="a00119.html">secure</a> * </td> <td class="paramname"><em>context</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>ciphers</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Assign a non-default cipher to the context. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">context</td><td>to set cipher for. </td></tr> <tr><td class="paramname">ciphers</td><td>to set. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a0b24e481a4338cd021ac2bc28e3b7a8e"></a><!-- doxytag: member="secure::client" ref="a0b24e481a4338cd021ac2bc28e3b7a8e" args="(const char *authority=NULL)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static <a class="el" href="a00119.html">client_t</a> secure::client </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>authority</em> = <code>NULL</code></td><td>)</td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Create an anonymous client context with an optional authority to validate. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">authority</td><td>path to use or NULL if none. </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>a basic client security context. </dd></dl> <dl><dt><b>Examples: </b></dt><dd><a class="el" href="a00004.html#a2">ssl.cpp</a>.</dd> </dl> </div> </div> <a class="anchor" id="a89f37590895e7e09e6797566037a47ed"></a><!-- doxytag: member="secure::err" ref="a89f37590895e7e09e6797566037a47ed" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname"><a class="el" href="a00119.html#ae94674293cfc03e24676257b4fe6b21f">error_t</a> secure::err </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td><td>)</td> <td><code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Get last error code associated with the security context. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>last error code or 0/OK if none. </dd></dl> <dl><dt><b>Examples: </b></dt><dd><a class="el" href="a00004.html#a3">ssl.cpp</a>.</dd> </dl> <p>Definition at line <a class="el" href="a00195_source.html#l00167">167</a> of file <a class="el" href="a00195_source.html">secure.h</a>.</p> </div> </div> <a class="anchor" id="ada0af1c61b17a135c90564d8158d93e4"></a><!-- doxytag: member="secure::init" ref="ada0af1c61b17a135c90564d8158d93e4" args="(const char *program=NULL)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static bool secure::init </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>program</em> = <code>NULL</code></td><td>)</td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Initialize secure stack for first use, and report if SSL support is compiled in. </p> <p>This allows a program name to be passed, which may be used for some proxy systems. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">program</td><td>name we are initializing for. </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>true if ssl support is available, false if not. </dd></dl> <dl><dt><b>Examples: </b></dt><dd><a class="el" href="a00006.html#a0">cipher.cpp</a>, and <a class="el" href="a00004.html#a1">ssl.cpp</a>.</dd> </dl> </div> </div> <a class="anchor" id="a0951415d4ba8bbebdf02fc9b4a40fd0f"></a><!-- doxytag: member="secure::is" ref="a0951415d4ba8bbebdf02fc9b4a40fd0f" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool secure::is </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td><td>)</td> <td><code> [inline]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Determine if the current security context is valid. </p> <dl class="return"><dt><b>Returns:</b></dt><dd>true if valid, -1 if not. </dd></dl> <p>Definition at line <a class="el" href="a00195_source.html#l00160">160</a> of file <a class="el" href="a00195_source.html">secure.h</a>.</p> </div> </div> <a class="anchor" id="a0f418366a2a74eadb48863970c7cd5c7"></a><!-- doxytag: member="secure::server" ref="a0f418366a2a74eadb48863970c7cd5c7" args="(const char *authority=NULL)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static <a class="el" href="a00119.html">server_t</a> secure::server </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>authority</em> = <code>NULL</code></td><td>)</td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Create a sever context. </p> <p>The certificate file used will be based on the <a class="el" href="a00119.html#ada0af1c61b17a135c90564d8158d93e4" title="Initialize secure stack for first use, and report if SSL support is compiled in.">init()</a> method name. This may often be /etc/ssl/certs/initname.pem. Similarly, a matching private key certificate will also be loaded. An optional certificate authority document can be used when we are establishing a service which ssl clients have their own certificates. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">authority</td><td>path to use or NULL if none. </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>a security context that is cast from derived library. </dd></dl> </div> </div> <a class="anchor" id="a5d52b3f052b5b41add1577a9264b95b3"></a><!-- doxytag: member="secure::user" ref="a5d52b3f052b5b41add1577a9264b95b3" args="(const char *authority)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static <a class="el" href="a00119.html">client_t</a> secure::user </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>authority</em></td><td>)</td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Create a peer user client context. </p> <p>This assumes a user certificate in ~/.ssl/certs and the user private key in ~/.ssl/private. The path to an authority is also sent. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">authority</td><td>path to use. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="aa7b0ccefea2af0a588f0d26509a69e80"></a><!-- doxytag: member="secure::uuid" ref="aa7b0ccefea2af0a588f0d26509a69e80" args="(char *string)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static void secure::uuid </td> <td>(</td> <td class="paramtype">char * </td> <td class="paramname"><em>string</em></td><td>)</td> <td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Create 36 character traditional version 1 uuid. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">string</td><td>to write uuid into, must be 37 bytes or more. </td></tr> </table> </dd> </dl> </div> </div> <a class="anchor" id="a367364c61f7f5f9765d1420b840a66fa"></a><!-- doxytag: member="secure::verify" ref="a367364c61f7f5f9765d1420b840a66fa" args="(session_t session, const char *peername=NULL)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">static <a class="el" href="a00119.html#ae94674293cfc03e24676257b4fe6b21f">error_t</a> secure::verify </td> <td>(</td> <td class="paramtype"><a class="el" href="a00119.html#adcd0244d9a8a05b793631922f90f0f17">session_t</a> </td> <td class="paramname"><em>session</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>peername</em> = <code>NULL</code> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td><code> [static]</code></td> </tr> </table> </div> <div class="memdoc"> <p>Verify a certificate chain through your certificate authority. </p> <p>This uses the ca loaded as an optional argument for client and server. Optionally the hostname of the connection can also be verified by pulling the peer certificate. </p> <dl><dt><b>Parameters:</b></dt><dd> <table class="params"> <tr><td class="paramname">session</td><td>that is connected. </td></tr> <tr><td class="paramname">peername</td><td>that we expect. </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>secure error level or secure::OK if none. </dd></dl> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li>ucommon/<a class="el" href="a00195_source.html">secure.h</a></li> </ul> </div> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="a00119.html">secure</a> </li> <li class="footer">Generated on Wed Apr 13 2011 22:39:48 for ucommon by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li> </ul> </div> </body> </html>