2013-10-03 3 views
0

나는 SecureStreamSocket에 연결된 StreamSocket을 첨부하려고 :POCO : 제대로 StreamSocket을 SecureStreamSocket에 연결하는 방법?

class MyConnection : public TCPServerConnection { 
    private: 
    Context::Ptr m_pContext; 
    public: 
    MyConnection(const StreamSocket& socket, Context::Ptr pContext) 
    : TCPServerConnection(socket), 
     m_pContext(pContext) 
    { 
    } 

    virtual void run() { 
     SecureStreamSocket secureSock(SecureStreamSocket::attach(socket(), m_pContext)); 
     socket() = secureSock; 
    } 
} 

을하지만 SSLException가 있습니다

SSL Exception [N4Poco3Net12SSLExceptionE]: error:140C5042:SSL routines:SSL_UNDEFINED_FUNCTION:called a function you should not call 

SSL 라이브러리의 초기화가 수행되었다 :

Poco::Net::initializeSSL(); // inside Application::initialize 

SSL 초기화 한 후 초기화 컨텍스트 :

,210

답변

0

우리는 SecureStreamSocket는 :: (...) 이런 식으로 연결 다시 작성할 수 있습니다 : this post에 대한

SecureStreamSocket SecureStreamSocket::attach(const StreamSocket& streamSocket, Context::Ptr pContext) 
{ 
    SecureStreamSocketImpl* pImpl = new SecureStreamSocketImpl(static_cast<StreamSocketImpl*>streamSocket.impl()), pContext); 
    SecureStreamSocket result(pImpl); 
    if (pImpl->context()->isForServerUse()) 
     pImpl->acceptSSL(); 
    else 
     pImpl->connectSSL(); 
    return result; 
} 

감사합니다. 이제는 서버와 클라이언트에서 잘 작동합니다.