diff --git a/src/base/http/server.cpp b/src/base/http/server.cpp index d89534656..1cc51eee2 100644 --- a/src/base/http/server.cpp +++ b/src/base/http/server.cpp @@ -47,6 +47,9 @@ Server::Server(IRequestHandler *requestHandler, QObject *parent) #endif { setProxy(QNetworkProxy::NoProxy); +#ifndef QT_NO_OPENSSL + QSslSocket::setDefaultCiphers(safeCipherList()); +#endif } Server::~Server() @@ -103,3 +106,26 @@ void Server::incomingConnection(int socketDescriptor) serverSocket->deleteLater(); } } + +#ifndef QT_NO_OPENSSL +QList Server::safeCipherList() const +{ + const QStringList badCiphers = {"idea", "rc4"}; + const QList allCiphers = QSslSocket::supportedCiphers(); + QList safeCiphers; + foreach (const QSslCipher &cipher, allCiphers) { + bool isSafe = true; + foreach (const QString &badCipher, badCiphers) { + if (cipher.name().contains(badCipher, Qt::CaseInsensitive)) { + isSafe = false; + break; + } + } + + if (isSafe) + safeCiphers += cipher; + } + + return safeCiphers; +} +#endif diff --git a/src/base/http/server.h b/src/base/http/server.h index b4eb492c3..7da8b5775 100644 --- a/src/base/http/server.h +++ b/src/base/http/server.h @@ -36,6 +36,7 @@ #include #ifndef QT_NO_OPENSSL #include +#include #include #endif @@ -68,6 +69,8 @@ namespace Http #endif #ifndef QT_NO_OPENSSL + QList safeCipherList() const; + bool m_https; QList m_certificates; QSslKey m_key;