0
我嘗試連接StreamSocket重視SecureStreamSocket: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初始化後上下文:
Poco::Net::Context::Ptr pContext =
new Poco::Net::Context(
Poco::Net::Context::SERVER_USE,
"server.key",
"server.crt",
"/path/to/certs/"
);