summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/ssl
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2022-09-01 13:44:36 +0200
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2022-09-01 20:10:03 +0200
commit8e21844683d46e777db3db74df0bcf76cb9a35c0 (patch)
treee4fa47bd883e572e466cbc94d0a546589f91d35b /tests/auto/network/ssl
parent67deefbaaa507fa4928cc683b561aa31f39b512e (diff)
tst_QSslKey - make OpenSSL v3 detection fully runtime
Otherwise, checks are useles in non-developer build. Pick-to: 6.4 6.3 6.2 Fixes: QTBUG-106036 Change-Id: I41b6d8f250021ff9fa4981f9df9244c269ed2999 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/network/ssl')
-rw-r--r--tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp
index ac42704b30..627b6cca98 100644
--- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp
+++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp
@@ -156,6 +156,7 @@ bool tst_QSslKey::fileContainsUnsupportedEllipticCurve(const QString &fileName)
bool tst_QSslKey::algorithmsSupported(const QString &fileName) const
{
+#if QT_CONFIG(ssl)
if (isSchannel && fileName.contains("RC2-64")) // Schannel treats RC2 as 128 bit
return false;
@@ -164,10 +165,9 @@ bool tst_QSslKey::algorithmsSupported(const QString &fileName) const
return !(fileName.contains(QRegularExpression("-aes\\d\\d\\d-")) || fileName.contains("pkcs8-pkcs12"));
}
-#if OPENSSL_VERSION_MAJOR < 3
- // If it's not built with OpenSSL or it's OpenSSL v < 3.
- return true;
-#else
+ if (!isOpenSsl || QSslSocket::sslLibraryVersionNumber() >> 28 < 3)
+ return true;
+
// OpenSSL v3 first introduced the notion of 'providers'. Many algorithms
// were moved into the 'legacy' provider. While they are still supported in theory,
// the 'legacy' provider is NOT loaded by default and we are not loading it either.
@@ -178,7 +178,10 @@ bool tst_QSslKey::algorithmsSupported(const QString &fileName) const
return false;
return !name.contains("-rc2-") && !name.contains("-rc4-");
-#endif
+#else
+ Q_UNUSED(fileName);
+ return false;
+#endif // QT_CONFIG(ssl)
}
@@ -545,12 +548,12 @@ void tst_QSslKey::passphraseChecks_data()
const QByteArray pass("123");
const QByteArray aesPass("1234");
-#if OPENSSL_VERSION_MAJOR < 3
- // DES and RC2 are not provided by default in OpenSSL v3.
- // This part is for either non-OpenSSL build, or OpenSSL v < 3.x.
- QTest::newRow("DES") << QString(testDataDir + "rsa-with-passphrase-des.pem") << pass;
- QTest::newRow("RC2") << QString(testDataDir + "rsa-with-passphrase-rc2.pem") << pass;
-#endif // OPENSSL_VERSION_MAJOR
+ if (!isOpenSsl || QSslSocket::sslLibraryVersionNumber() >> 28 < 3) {
+ // DES and RC2 are not provided by default in OpenSSL v3.
+ // This part is for either non-OpenSSL build, or OpenSSL v < 3.x.
+ QTest::newRow("DES") << QString(testDataDir + "rsa-with-passphrase-des.pem") << pass;
+ QTest::newRow("RC2") << QString(testDataDir + "rsa-with-passphrase-rc2.pem") << pass;
+ }
QTest::newRow("3DES") << QString(testDataDir + "rsa-with-passphrase-3des.pem") << pass;