blocxx
|
00001 /******************************************************************************* 00002 * Copyright (C) 2005, Vintela, Inc. All rights reserved. 00003 * Copyright (C) 2006, Novell, Inc. All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * * Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Neither the name of 00014 * Vintela, Inc., 00015 * nor Novell, Inc., 00016 * nor the names of its contributors or employees may be used to 00017 * endorse or promote products derived from this software without 00018 * specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00021 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00022 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00023 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00024 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00025 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00026 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00029 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00030 * POSSIBILITY OF SUCH DAMAGE. 00031 *******************************************************************************/ 00032 00033 00042 #ifndef BLOCXX_INETSSLSOCKETIMPL_HPP_INCLUDE_GUARD_ 00043 #define BLOCXX_INETSSLSOCKETIMPL_HPP_INCLUDE_GUARD_ 00044 #include "blocxx/BLOCXX_config.h" 00045 #include "blocxx/SocketBaseImpl.hpp" 00046 #include "blocxx/SSLCtxMgr.hpp" 00047 #include "blocxx/SSLException.hpp" 00048 #ifndef BLOCXX_NO_SSL 00049 00050 // The classes and functions defined in this file are not meant for general 00051 // use, they are internal implementation details. They may change at any time. 00052 00053 namespace BLOCXX_NAMESPACE 00054 { 00055 00056 class BLOCXX_COMMON_API SSLSocketImpl : public SocketBaseImpl 00057 { 00058 public: 00059 SSLSocketImpl(SSLClientCtxRef sslCtx); 00060 00061 // DEPRECATED, but not because it's an impl 00062 SSLSocketImpl() ; 00068 SSLSocketImpl(SocketHandle_t fd, SocketAddress::AddressType addrType, 00069 const SSLServerCtxRef& sslCtx); 00076 // Deprecated, but not really since this is an impl. 00077 SSLSocketImpl(SocketHandle_t fd, SocketAddress::AddressType addrType); 00081 SSLSocketImpl(const SocketAddress& addr); 00082 virtual ~SSLSocketImpl(); 00086 virtual void connect(const SocketAddress& addr); 00087 virtual void disconnect(); 00088 Select_t getSelectObj() const; 00093 SSL* getSSL() const; 00094 00099 bool peerCertVerified() const; 00100 private: 00104 virtual int readAux(void* dataIn, int dataInLen); 00108 virtual int writeAux(const void* dataOut, int dataOutLen); 00109 void connectSSL(); 00110 virtual bool waitForInput(const Timeout& timeout); 00111 SSL* m_ssl; 00112 BIO* m_sbio; 00113 00114 #ifdef BLOCXX_WIN32 00115 #pragma warning (push) 00116 #pragma warning (disable: 4251) 00117 #endif 00118 00119 SSLClientCtxRef m_sslCtx; 00120 00121 #ifdef BLOCXX_WIN32 00122 #pragma warning (pop) 00123 #endif 00124 00125 OWSSLContext m_owctx; 00126 00127 SSLSocketImpl(const SSLSocketImpl& arg); 00128 SSLSocketImpl& operator =(const SSLSocketImpl& arg); 00129 }; 00130 00131 } // end namespace BLOCXX_NAMESPACE 00132 00133 #endif // #ifndef BLOCXX_NO_SSL 00134 00135 #endif