drogon
drogon copied to clipboard
A way to get USE_SSL attribute from listener
Hi,
There is any way to know if a listener is using SSL? I can get the port and host, but not "use ssl" option from listener.
int32_t HttpServerImpl::getSocketPort()
{
return drogon::app().getListeners()[0].toPort();
}
std::string HttpServerImpl::getSocketHost()
{
return drogon::app().getListeners()[0].toIp();
}
Thanks.
Sorry for the late reply. Why do you need access to a listener? You can query if a HTTP request is revived using req->isOnSecureConnection()
I only want show if the user can open the server in HTTP or HTTPS when i show the message on terminal.
https://github.com/nativium/nativium-http-server
In that case you can modify addListener
void ListenerManager::addListener(...)
{
#ifndef OpenSSL_FOUND
if (useSSL)
{
LOG_ERROR << "Can't use SSL without OpenSSL found in your system";
}
#endif
LOG_INFO << "Adding listener: " << ip << ":" << port << ", ssl: "
<< useSSL;
listeners_.emplace_back(
ip, port, useSSL, certFile, keyFile, useOldTLS, sslConfCmds);
}
Or TcpServer
void TcpServer::start()
{
if(sslCtxPtr_)
LOG_INFO << "SSL is enabled, listening on " << ipPort();
As of now there's API visible for programs to query this