From 37d9e44cd010c9844b0dbe2b25f307eab15b3ea8 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 12 Jun 2020 11:11:08 +0200 Subject: QSslConfiguration::setCiphers - introduce the overload taking QString MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We had such an overloaded version in QSslSocket, it was deprecated without providing any alternative. Now this function has some use and may be introduced in Qt6, as QSslConfiguration::setCiphers(const QString &). Last but not the least - a useless and strange auto-test was removed (it was creating a list of 5 QSslCiphers each with isNull() == true). That's becasue '!MD5' or 'ALL' (for example) is not a cipher to be found in supportedCiphers. Change-Id: I47eb4c0faa9b52885e883751dd992cd9cb3d26fe Reviewed-by: MÃ¥rten Nordheim --- .../auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'tests/auto/network/ssl') diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 97a01efdd3..864d8db008 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -804,10 +804,30 @@ void tst_QSslSocket::ciphers() socket.setSslConfiguration(sslConfig); QCOMPARE(socket.sslConfiguration().ciphers(), QSslConfiguration::defaultConfiguration().ciphers()); - // Task 164356 - sslConfig.setCiphers({QSslCipher("ALL"), QSslCipher("!ADH"), QSslCipher("!LOW"), - QSslCipher("!EXP"), QSslCipher("!MD5"), QSslCipher("@STRENGTH")}); + sslConfig = QSslConfiguration::defaultConfiguration(); + QList ciphers; + QString ciphersAsString; + const auto &supported = sslConfig.supportedCiphers(); + for (const auto &cipher : supported) { + if (cipher.isNull() || !cipher.name().length()) + continue; + if (ciphers.size() > 0) + ciphersAsString += QStringLiteral(":"); + ciphersAsString += cipher.name(); + ciphers.append(cipher); + if (ciphers.size() == 3) // 3 should be enough. + break; + } + + if (!ciphers.size()) + QSKIP("No proper ciphersuite was found to test 'setCiphers'"); + + sslConfig.setCiphers(ciphersAsString); + socket.setSslConfiguration(sslConfig); + QCOMPARE(ciphers, socket.sslConfiguration().ciphers()); + sslConfig.setCiphers(ciphers); socket.setSslConfiguration(sslConfig); + QCOMPARE(ciphers, socket.sslConfiguration().ciphers()); } void tst_QSslSocket::connectToHostEncrypted() -- cgit v1.2.3