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