<!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> <title>Class Poco::Net::SecureSocketImpl</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <meta name="author" content="Applied Informatics Software Engineering GmbH and Contributors"/> <meta name="publisher" content="Applied Informatics Software Engineering GmbH and Contributors"/> <meta name="copyright" content="Copyright (c) 2009, Applied Informatics Software Engineering GmbH and Contributors"/> <meta name="language" content="en"/> <meta name="date" content="2009-11-24"/> <meta name="generator" content="PocoDoc"/> <link rel="stylesheet" href="css/styles.css" type="text/css"/> </head> <body bgcolor="#ffffff" leftmargin="0" topmargin="0"> <div class="header"> <h1 class="namespace"><a href="Poco.Net.html" class="namespace">Poco::Net</a></h1> <h1 class="symbol">class SecureSocketImpl</h1> </div> <div class="body"> <p> <b>Library:</b> NetSSL_OpenSSL<br /> <b>Package:</b> SSLSockets<br /> <b>Header:</b> Poco/Net/SecureSocketImpl.h</p> <h2>Description</h2> <div class="description"> <p>The <a href="Poco.Net.SocketImpl.html" title="class Poco::Net::SocketImpl">SocketImpl</a> for <a href="Poco.Net.SecureStreamSocket.html" title="class Poco::Net::SecureStreamSocket">SecureStreamSocket</a>. </p> </div> <h2>Member Summary</h2> <p><b>Member Functions: </b><a href="Poco.Net.SecureSocketImpl.html#16089" title="Poco::Net::SecureSocketImpl::acceptConnection()">acceptConnection</a>, <a href="Poco.Net.SecureSocketImpl.html#16125" title="Poco::Net::SecureSocketImpl::acceptSSL()">acceptSSL</a>, <a href="Poco.Net.SecureSocketImpl.html#16100" title="Poco::Net::SecureSocketImpl::bind()">bind</a>, <a href="Poco.Net.SecureSocketImpl.html#16106" title="Poco::Net::SecureSocketImpl::close()">close</a>, <a href="Poco.Net.SecureSocketImpl.html#16115" title="Poco::Net::SecureSocketImpl::completeHandshake()">completeHandshake</a>, <a href="Poco.Net.SecureSocketImpl.html#16091" title="Poco::Net::SecureSocketImpl::connect()">connect</a>, <a href="Poco.Net.SecureSocketImpl.html#16098" title="Poco::Net::SecureSocketImpl::connectNB()">connectNB</a>, <a href="Poco.Net.SecureSocketImpl.html#16126" title="Poco::Net::SecureSocketImpl::connectSSL()">connectSSL</a>, <a href="Poco.Net.SecureSocketImpl.html#16118" title="Poco::Net::SecureSocketImpl::context()">context</a>, <a href="Poco.Net.SecureSocketImpl.html#16124" title="Poco::Net::SecureSocketImpl::getPeerHostName()">getPeerHostName</a>, <a href="Poco.Net.SecureSocketImpl.html#16132" title="Poco::Net::SecureSocketImpl::handleError()">handleError</a>, <a href="Poco.Net.SecureSocketImpl.html#16130" title="Poco::Net::SecureSocketImpl::isLocalHost()">isLocalHost</a>, <a href="Poco.Net.SecureSocketImpl.html#16103" title="Poco::Net::SecureSocketImpl::listen()">listen</a>, <a href="Poco.Net.SecureSocketImpl.html#16117" title="Poco::Net::SecureSocketImpl::peerCertificate()">peerCertificate</a>, <a href="Poco.Net.SecureSocketImpl.html#16111" title="Poco::Net::SecureSocketImpl::receiveBytes()">receiveBytes</a>, <a href="Poco.Net.SecureSocketImpl.html#16134" title="Poco::Net::SecureSocketImpl::reset()">reset</a>, <a href="Poco.Net.SecureSocketImpl.html#16107" title="Poco::Net::SecureSocketImpl::sendBytes()">sendBytes</a>, <a href="Poco.Net.SecureSocketImpl.html#16122" title="Poco::Net::SecureSocketImpl::setPeerHostName()">setPeerHostName</a>, <a href="Poco.Net.SecureSocketImpl.html#16105" title="Poco::Net::SecureSocketImpl::shutdown()">shutdown</a>, <a href="Poco.Net.SecureSocketImpl.html#16116" title="Poco::Net::SecureSocketImpl::sockfd()">sockfd</a>, <a href="Poco.Net.SecureSocketImpl.html#16128" title="Poco::Net::SecureSocketImpl::verifyCertificate()">verifyCertificate</a>, <a href="Poco.Net.SecureSocketImpl.html#16119" title="Poco::Net::SecureSocketImpl::verifyPeerCertificate()">verifyPeerCertificate</a></p> <h2>Constructors</h2> <h3><a name="16085">SecureSocketImpl</a></h3> <p class="decl"><a href="Poco.Net.SecureSocketImpl.html" title="class Poco::Net::SecureSocketImpl">SecureSocketImpl</a>(<br /> <a href="Poco.AutoPtr.html" title="class Poco::AutoPtr">Poco::AutoPtr</a> < <a href="Poco.Net.SocketImpl.html" title="class Poco::Net::SocketImpl">SocketImpl</a> > pSocketImpl,<br /> <a href="Poco.Net.Context.html#15711" title="Poco::Net::Context::Ptr">Context::Ptr</a> pContext<br />);</p> <div class="description"> <p>Creates the <a href="Poco.Net.SecureSocketImpl.html" title="class Poco::Net::SecureSocketImpl">SecureSocketImpl</a> using an already connected stream socket. </p> </div> <h2>Destructor</h2> <h3><a name="16088">~SecureSocketImpl</a> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3> <p class="decl">virtual ~<a href="Poco.Net.SecureSocketImpl.html" title="class Poco::Net::SecureSocketImpl">SecureSocketImpl</a>();</p> <div class="description"> <p>Destroys the <a href="Poco.Net.SecureSocketImpl.html" title="class Poco::Net::SecureSocketImpl">SecureSocketImpl</a>. </p> </div> <h2>Member Functions</h2> <h3><a name="16089">acceptConnection</a></h3> <p class="decl"><a href="Poco.Net.SocketImpl.html" title="class Poco::Net::SocketImpl">SocketImpl</a> * acceptConnection(<br /> <a href="Poco.Net.SocketAddress.html" title="class Poco::Net::SocketAddress">SocketAddress</a> & clientAddr<br />);</p> <div class="description"> <p>Get the next completed connection from the socket's completed connection queue. </p> <p>If the queue is empty, waits until a connection request completes. </p> <p>Returns a new SSL socket for the connection with the client. </p> <p>The client socket's address is returned in clientAddr. </p> </div> <h3><a name="16100">bind</a></h3> <p class="decl">void bind(<br /> const <a href="Poco.Net.SocketAddress.html" title="class Poco::Net::SocketAddress">SocketAddress</a> & address,<br /> bool reuseAddress = false<br />);</p> <div class="description"> <p>Bind a local address to the socket. </p> <p>This is usually only done when establishing a server socket. SSL clients should not bind a socket to a specific address. </p> <p>If reuseAddress is true, sets the SO_REUSEADDR socket option. </p> </div> <h3><a name="16106">close</a></h3> <p class="decl">void close();</p> <div class="description"> <p>Close the socket. </p> </div> <h3><a name="16115">completeHandshake</a></h3> <p class="decl">int completeHandshake();</p> <div class="description"> <p>Completes the SSL handshake. </p> <p>If the SSL connection was the result of an accept(), the server-side handshake is completed, otherwise a client-side handshake is performed. </p> </div> <h3><a name="16091">connect</a></h3> <p class="decl">void connect(<br /> const <a href="Poco.Net.SocketAddress.html" title="class Poco::Net::SocketAddress">SocketAddress</a> & address,<br /> bool performHandshake<br />);</p> <div class="description"> <p>Initializes the socket and establishes a secure connection to the TCP server at the given address. </p> <p>If performHandshake is true, the SSL handshake is performed immediately after establishing the connection. Otherwise, the handshake is performed the first time <a href="Poco.Net.SecureSocketImpl.html#16107" title="Poco::Net::SecureSocketImpl::sendBytes()">sendBytes</a>(), <a href="Poco.Net.SecureSocketImpl.html#16111" title="Poco::Net::SecureSocketImpl::receiveBytes()">receiveBytes</a>() or <a href="Poco.Net.SecureSocketImpl.html#16115" title="Poco::Net::SecureSocketImpl::completeHandshake()">completeHandshake</a>() is called. </p> </div> <h3><a name="16094">connect</a></h3> <p class="decl">void connect(<br /> const <a href="Poco.Net.SocketAddress.html" title="class Poco::Net::SocketAddress">SocketAddress</a> & address,<br /> const <a href="Poco.Timespan.html" title="class Poco::Timespan">Poco::Timespan</a> & timeout,<br /> bool performHandshake<br />);</p> <div class="description"> <p>Initializes the socket, sets the socket timeout and establishes a secure connection to the TCP server at the given address. </p> <p>If performHandshake is true, the SSL handshake is performed immediately after establishing the connection. Otherwise, the handshake is performed the first time <a href="Poco.Net.SecureSocketImpl.html#16107" title="Poco::Net::SecureSocketImpl::sendBytes()">sendBytes</a>(), <a href="Poco.Net.SecureSocketImpl.html#16111" title="Poco::Net::SecureSocketImpl::receiveBytes()">receiveBytes</a>() or <a href="Poco.Net.SecureSocketImpl.html#16115" title="Poco::Net::SecureSocketImpl::completeHandshake()">completeHandshake</a>() is called. </p> </div> <h3><a name="16098">connectNB</a></h3> <p class="decl">void connectNB(<br /> const <a href="Poco.Net.SocketAddress.html" title="class Poco::Net::SocketAddress">SocketAddress</a> & address<br />);</p> <div class="description"> <p>Initializes the socket and establishes a secure connection to the TCP server at the given address. Prior to opening the connection the socket is set to nonblocking mode. </p> </div> <h3><a name="16118">context</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3> <p class="decl"><a href="Poco.Net.Context.html#15711" title="Poco::Net::Context::Ptr">Context::Ptr</a> context() const;</p> <div class="description"> <p>Returns the SSL context used for this socket. </p> </div> <h3><a name="16124">getPeerHostName</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3> <p class="decl">const std::string & getPeerHostName() const;</p> <div class="description"> <p>Returns the peer host name. </p> </div> <h3><a name="16103">listen</a></h3> <p class="decl">void listen(<br /> int backlog = 64<br />);</p> <div class="description"> <p>Puts the socket into listening state. </p> <p>The socket becomes a passive socket that can accept incoming connection requests. </p> <p>The backlog argument specifies the maximum number of connections that can be queued for this socket. </p> </div> <h3><a name="16117">peerCertificate</a></h3> <p class="decl">X509 * peerCertificate() const;</p> <div class="description"> <p>Returns the peer's certificate. </p> </div> <h3><a name="16111">receiveBytes</a></h3> <p class="decl">int receiveBytes(<br /> void * buffer,<br /> int length,<br /> int flags = 0<br />);</p> <div class="description"> <p>Receives data from the socket and stores it in buffer. Up to length bytes are received. </p> <p>Returns the number of bytes received. </p> </div> <h3><a name="16107">sendBytes</a></h3> <p class="decl">int sendBytes(<br /> const void * buffer,<br /> int length,<br /> int flags = 0<br />);</p> <div class="description"> <p>Sends the contents of the given buffer through the socket. <a href="Poco.Any.html" title="class Poco::Any">Any</a> specified flags are ignored. </p> <p>Returns the number of bytes sent, which may be less than the number of bytes specified. </p> </div> <h3><a name="16122">setPeerHostName</a></h3> <p class="decl">void setPeerHostName(<br /> const std::string & hostName<br />);</p> <div class="description"> <p>Sets the peer host name for certificate validation purposes. </p> </div> <h3><a name="16105">shutdown</a></h3> <p class="decl">void shutdown();</p> <div class="description"> <p>Shuts down the connection by attempting an orderly SSL shutdown, then actually shutting down the TCP connection. </p> </div> <h3><a name="16116">sockfd</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3> <p class="decl">int sockfd();</p> <div class="description"> <p>Returns the underlying socket descriptor. </p> </div> <h3><a name="16119">verifyPeerCertificate</a></h3> <p class="decl">void verifyPeerCertificate();</p> <div class="description"> <p>Performs post-connect (or post-accept) peer certificate validation, using the peer host name set with <a href="Poco.Net.SecureSocketImpl.html#16122" title="Poco::Net::SecureSocketImpl::setPeerHostName()">setPeerHostName</a>(), or the peer's IP address string if no peer host name has been set. </p> </div> <h3><a name="16120">verifyPeerCertificate</a></h3> <p class="decl">void verifyPeerCertificate(<br /> const std::string & hostName<br />);</p> <div class="description"> <p>Performs post-connect (or post-accept) peer certificate validation using the given peer host name. </p> </div> <h3><a name="16125">acceptSSL</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3> <p class="decl">void acceptSSL();</p> <div class="description"> <p>Performs a server-side SSL handshake and certificate verification. </p> </div> <h3><a name="16126">connectSSL</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3> <p class="decl">void connectSSL(<br /> bool performHandshake<br />);</p> <div class="description"> <p>Performs a client-side SSL handshake and establishes a secure connection over an already existing TCP connection. </p> </div> <h3><a name="16132">handleError</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3> <p class="decl">int handleError(<br /> int rc<br />);</p> <div class="description"> <p>Handles an SSL error by throwing an appropriate exception. </p> </div> <h3><a name="16130">isLocalHost</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/static.gif" alt="static" title="static" style="vertical-align:baseline;" border="0" /> </h3> <p class="decl">static bool isLocalHost(<br /> const std::string & hostName<br />);</p> <div class="description"> <p>Returns true if and only if the given host name is the local host (either "localhost" or "127.0.0.1"). </p> </div> <h3><a name="16134">reset</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3> <p class="decl">void reset();</p> <div class="description"> <p>Prepares the socket for re-use. </p> <p>After closing and resetting a socket, the socket can be used for a new connection. </p> <p>Note that simply closing a socket is not sufficient to be able to re-use it again. </p> </div> <h3><a name="16128">verifyCertificate</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3> <p class="decl">long verifyCertificate(<br /> const std::string & hostName<br />);</p> <div class="description"> <p>Performs post-connect (or post-accept) peer certificate validation. </p> </div> <p class="footer">POCO C++ Libraries 1.3.6-all<br /> Copyright © 2009, <a href="http://pocoproject.org/" target="_blank">Applied Informatics Software Engineering GmbH and Contributors</a></p> </div> </body> </html>