我尝试将连接的 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/"
);