Add missing call to setSocketDescriptor().
This commit is contained in:
@@ -30,8 +30,7 @@
|
|||||||
#include "qhttpengine_global.h"
|
#include "qhttpengine_global.h"
|
||||||
|
|
||||||
#if !defined(QT_NO_SSL)
|
#if !defined(QT_NO_SSL)
|
||||||
class QSslCertificate;
|
class QSslConfiguration;
|
||||||
class QSslKey;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class QHttpHandler;
|
class QHttpHandler;
|
||||||
@@ -85,14 +84,12 @@ public:
|
|||||||
|
|
||||||
#if !defined(QT_NO_SSL)
|
#if !defined(QT_NO_SSL)
|
||||||
/**
|
/**
|
||||||
* @brief Set the certificate to use for TLS
|
* @brief Set the SSL configuration for the server
|
||||||
|
*
|
||||||
|
* If the configuration is not NULL, the server will begin negotiating
|
||||||
|
* connections using SSL/TLS.
|
||||||
*/
|
*/
|
||||||
void setCertificate(const QSslCertificate &certificate);
|
void setSslConfiguration(const QSslConfiguration &configuration);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the private key to use for TLS
|
|
||||||
*/
|
|
||||||
void setPrivateKey(const QSslKey &key);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -72,14 +72,9 @@ void QHttpServer::setHandler(QHttpHandler *handler)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(QT_NO_SSL)
|
#if !defined(QT_NO_SSL)
|
||||||
void QHttpServer::setCertificate(const QSslCertificate &certificate)
|
void QHttpServer::setSslConfiguration(const QSslConfiguration &configuration)
|
||||||
{
|
{
|
||||||
d->configuration.setLocalCertificate(certificate);
|
d->configuration = configuration;
|
||||||
}
|
|
||||||
|
|
||||||
void QHttpServer::setPrivateKey(const QSslKey &key)
|
|
||||||
{
|
|
||||||
d->configuration.setPrivateKey(key);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -89,22 +84,25 @@ void QHttpServer::incomingConnection(qintptr socketDescriptor)
|
|||||||
if (!d->configuration.isNull()) {
|
if (!d->configuration.isNull()) {
|
||||||
|
|
||||||
// Initialize the socket with the SSL configuration
|
// Initialize the socket with the SSL configuration
|
||||||
QSslSocket *sslSocket = new QSslSocket(this);
|
QSslSocket *socket = new QSslSocket(this);
|
||||||
|
|
||||||
// Wait until encryption is complete before processing the socket
|
// Wait until encryption is complete before processing the socket
|
||||||
connect(sslSocket, &QSslSocket::encrypted, [this, sslSocket]() {
|
connect(socket, &QSslSocket::encrypted, [this, socket]() {
|
||||||
d->process(sslSocket);
|
d->process(socket);
|
||||||
});
|
});
|
||||||
|
|
||||||
sslSocket->setSocketDescriptor(socketDescriptor);
|
socket->setSocketDescriptor(socketDescriptor);
|
||||||
sslSocket->setSslConfiguration(d->configuration);
|
socket->setSslConfiguration(d->configuration);
|
||||||
sslSocket->startServerEncryption();
|
socket->startServerEncryption();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QTcpSocket *socket = new QTcpSocket(this);
|
||||||
|
socket->setSocketDescriptor(socketDescriptor);
|
||||||
|
|
||||||
// Process the socket immediately
|
// Process the socket immediately
|
||||||
d->process(new QTcpSocket(this));
|
d->process(socket);
|
||||||
|
|
||||||
#if !defined(QT_NO_SSL)
|
#if !defined(QT_NO_SSL)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user