📄 classsslsocket.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>SSLSocket class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center>
<hr><h1>SSLSocket Class Reference</h1><code>#include <<a class="el" href="sslsocket_8h-source.html">sslsocket.h</a>></code>
<p>
<p>Inheritance diagram for SSLSocket:
<p><center><img src="classSSLSocket.png" usemap="#SSLSocket_map" border="0"></center>
<map name="SSLSocket_map">
<area href="classSocket.html" alt="Socket" shape="rect" coords="42,56,116,80">
<area href="classLogger.html" alt="Logger" shape="rect" coords="42,0,116,24">
<area href="classInetSocket.html" alt="InetSocket" shape="rect" coords="0,168,74,192">
<area href="classUnixSocket.html" alt="UnixSocket" shape="rect" coords="84,168,158,192">
</map>
<a href="classSSLSocket-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td colspan=2><br><h2>Public Types</h2></td></tr>
<tr><td nowrap align=right valign=top>enum </td><td valign=bottom><a class="el" href="classSSLSocket.html#s2">SSL_OPTS</a> { <b>VERIFY_PEER</b>,
<b>VERIFY_NONE</b>
}</td></tr>
<tr><td colspan=2><br><h2>Public Methods</h2></td></tr>
<tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classSSLSocket.html#a0">SSLSocket</a> (const string &<a class="el" href="classSocket.html#n0">host</a>)</td></tr>
<tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classSSLSocket.html#a1">SSLSocket</a> (const string &<a class="el" href="classSocket.html#n0">host</a>, int fd)</td></tr>
<tr><td nowrap align=right valign=top>virtual </td><td valign=bottom><a class="el" href="classSSLSocket.html#a2">~SSLSocket</a> ()</td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classSSLSocket.html#a3">readSocket</a> ()</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSSLSocket.html#a4">writeSocket</a> (const string &data)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSSLSocket.html#a5">setSSLOpts</a> (<a class="el" href="classSSLSocket.html#s2">SSL_OPTS</a> opts)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSSLSocket.html#a6">setVerifyLocations</a> (const string &<a class="el" href="classSSLSocket.html#n4">ca_file</a>, const string &<a class="el" href="classSSLSocket.html#n5">ca_dir</a>)</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSSLSocket.html#a7">negotiate</a> ()</td></tr>
<tr><td colspan=2><br><h2>Protected Methods</h2></td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSSLSocket.html#b0">dumpSSLInfo</a> ()</td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classSSLSocket.html#b1">ssl_readSocket</a> ()</td></tr>
<tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classSSLSocket.html#b2">ssl_writeSocket</a> (const string &data)</td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classSSLSocket.html#b3">ssl_error</a> (int ret=65536)</td></tr>
<tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classSSLSocket.html#b4">ssl_read</a> (SSL *<a class="el" href="classSSLSocket.html#n1">ssl</a>, void *buf, int num)</td></tr>
<tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classSSLSocket.html#b5">ssl_write</a> (SSL *<a class="el" href="classSSLSocket.html#n1">ssl</a>, const void *buf, int num)</td></tr>
<tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classSSLSocket.html#b6">ssl_connect</a> (SSL *<a class="el" href="classSSLSocket.html#n1">ssl</a>)</td></tr>
<tr><td colspan=2><br><h2>Protected Attributes</h2></td></tr>
<tr><td nowrap align=right valign=top>SSL_CTX * </td><td valign=bottom><a class="el" href="classSSLSocket.html#n0">ctx</a></td></tr>
<tr><td nowrap align=right valign=top>SSL * </td><td valign=bottom><a class="el" href="classSSLSocket.html#n1">ssl</a></td></tr>
<tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="classSSLSocket.html#n2">negotiated</a></td></tr>
<tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classSSLSocket.html#n3">verify</a></td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classSSLSocket.html#n4">ca_file</a></td></tr>
<tr><td nowrap align=right valign=top>string </td><td valign=bottom><a class="el" href="classSSLSocket.html#n5">ca_dir</a></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
This class describes a socket with SSL extensions. This class is intended to be a base class for more specific socket implementations, eg. tcp sockets or unix domain sockets. Consequently it is a virtual class that cannot be instantiated.
<p>
<dl compact><dt><b>
Author: </b><dd>
Timo Benk <<a href="mailto:t_benk@web.de">t_benk@web.de</a>> </dl>
<p>
<hr><h2>Member Enumeration Documentation</h2>
<a name="s2" doxytag="SSLSocket::SSL_OPTS"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> enum SSLSocket::SSL_OPTS
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
The ssl protocol options that can be customized. VERIFY_PEER will ensure that the certificate provided by the <a class="el" href="classSMTP.html">SMTP</a> server is valid. VERIFY_NONE will skip verification of the certificate. </td>
</tr>
</table>
<hr><h2>Constructor & Destructor Documentation</h2>
<a name="a0" doxytag="SSLSocket::SSLSocket"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> SSLSocket::SSLSocket </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const string & </td>
<td class="mdname1" valign="top" nowrap> <em>host</em> </td>
<td class="md" valign="top">) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Constructor.<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>host</em> </td><td>
The host this socket is connected to. </td></tr>
</table>
</dl> </td>
</tr>
</table>
<a name="a1" doxytag="SSLSocket::SSLSocket"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> SSLSocket::SSLSocket </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const string & </td>
<td class="mdname" nowrap> <em>host</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>int </td>
<td class="mdname" nowrap> <em>fd</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Constructor.<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>host</em> </td><td>
The host this socket is connected to. </td></tr>
<tr><td valign=top><em>fd</em> </td><td>
The file descriptor this socket uses for IO. </td></tr>
</table>
</dl> </td>
</tr>
</table>
<a name="a2" doxytag="SSLSocket::~SSLSocket"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> SSLSocket::~SSLSocket </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">) </td>
<td class="md" nowrap><code> [virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Destructor. </td>
</tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a name="b0" doxytag="SSLSocket::dumpSSLInfo"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void SSLSocket::dumpSSLInfo </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">) </td>
<td class="md" nowrap><code> [protected]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Dump various X509 Infos. </td>
</tr>
</table>
<a name="a7" doxytag="SSLSocket::negotiate"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void SSLSocket::negotiate </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Start the SSL handshake.<dl compact><dt><b>
Exceptions: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em><a class="el" href="classSSLException.html">SSLException</a></em> </td><td>
If the handshake fails for some reason. </td></tr>
<tr><td valign=top><em><a class="el" href="classIOException.html">IOException</a></em> </td><td>
If one of ca_file or ca_dir is not accessible. </td></tr>
</table>
</dl> </td>
</tr>
</table>
<a name="a3" doxytag="SSLSocket::readSocket"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> string SSLSocket::readSocket </td>
<td class="md" valign="top">( </td>
<td class="mdname1" valign="top" nowrap> </td>
<td class="md" valign="top">) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Reads one line from the socket.
<p>
<dl compact><dt><b>
Returns: </b><dd>
One line read from the socket.</dl><dl compact><dt><b>
Exceptions: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em><a class="el" href="classTransferException.html">TransferException</a></em> </td><td>
On any uncommon event that occurs while receiving the data. </td></tr>
<tr><td valign=top><em><a class="el" href="classSSLException.html">SSLException</a></em> </td><td>
On any uncommon event that occurs while receiving data from the encrypted socket. </td></tr>
</table>
</dl>
<p>
Reimplemented from <a class="el" href="classSocket.html#a5">Socket</a>. </td>
</tr>
</table>
<a name="a5" doxytag="SSLSocket::setSSLOpts"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void SSLSocket::setSSLOpts </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top"><a class="el" href="classSSLSocket.html#s2">SSL_OPTS</a> </td>
<td class="mdname1" valign="top" nowrap> <em>opts</em> </td>
<td class="md" valign="top">) </td>
<td class="md" nowrap></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Set some SSL specific options.<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>opts</em> </td><td>
The option that should be set. </td></tr>
</table>
</dl> </td>
</tr>
</table>
<a name="a6" doxytag="SSLSocket::setVerifyLocations"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> void SSLSocket::setVerifyLocations </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const string & </td>
<td class="mdname" nowrap> <em>ca_file</em>, </td>
</tr>
<tr>
<td></td>
<td></td>
<td class="md" nowrap>const string & </td>
<td class="mdname" nowrap> <em>ca_dir</em></td>
</tr>
<tr>
<td></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
</td>
<td>
<p>
Set the locations of the certificate files. ca_file points to a file containing PEM certs, ca_dir points to a directory containing PEM certs. "man 3 SSL_CTX_load_verify_locations" will give you more info on that topic.<dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>ca_file</em> </td><td>
A file that contains PEM certificates. The file can contain several CA certificates identified by</td></tr>
</table>
</dl>-----BEGIN CERTIFICATE-----
<p>
... [CA certificate in base64 encoding] ...
<p>
-----END CERTIFICATE-----
<p>
sequences. Before, between, and after the certificates text is allowed which can be used e.g. for descriptions of the certificates.
<p>
Take a look in the openssl documentation to get more infos on that topic. <dl compact><dt><b>
Parameters: </b><dd>
<table border=0 cellspacing=2 cellpadding=0>
<tr><td valign=top><em>ca_dir</em> </td><td>
A directory that contains PEM certificates. The files each contain one CA certificate. The files are looked up by the CA subject name hash value, which must hence be available. If more than one CA certificate with the same name hash value exist, the extension must be different (e.g. 9d66eef0.0, 9d66eef0.1 etc). The search is performed in the ordering of the extension number, regardless of other properties of the certificates. Use the c_rehash utility to create the necessary links.</td></tr>
</table>
</dl>Take a look in the openssl documentation to get more infos on that topic. </td>
</tr>
</table>
<a name="b6" doxytag="SSLSocket::ssl_connect"></a><p>
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td class="md">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> int SSLSocket::ssl_connect </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">SSL * </td>
<td class="mdname1" valign="top" nowrap> <em>ssl</em> </td>
<td class="md" valign="top">) </td>
<td class="md" nowrap><code> [protected]</code></td>
</tr>
</table>
</td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -