diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2020-06-15 16:23:28 +0200 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2020-06-22 12:11:47 +0200 |
commit | c2bf56fc3a65cbd6a2a94234a87d8ede4003efe6 (patch) | |
tree | 8e701d0c1b00f1b761e547919a1a1cc06677aaf9 /tests/auto/network/ssl | |
parent | 29d3e7ce38abd09c85d9b28fbc2f89a16fb155c2 (diff) |
QSslSocket: remove certificate-related setters
They were deprecated with replacements in QSslConfiguration proposed (and
some without alternative, which we'll provide if there is any demand
in such an API). Special thanks to M.N. for a nice hint on how to
amend the test without introducing a new API.
Change-Id: I7841a5b3f30469d8204b61cb65921c34275e0650
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/network/ssl')
-rw-r--r-- | tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index 329e3e367d..ee2b05aada 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -32,6 +32,7 @@ #include <qsslkey.h> #include <qsslsocket.h> #include <qsslcertificateextension.h> +#include <qscopeguard.h> #ifndef QT_NO_OPENSSL #include <openssl/obj_mac.h> @@ -1000,11 +1001,15 @@ void tst_QSslCertificate::verify() // Verify a valid cert signed by a CA QList<QSslCertificate> caCerts = QSslCertificate::fromPath(testDataDir + "verify-certs/cacert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); - -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - QSslSocket::addDefaultCaCertificate(caCerts.first()); -QT_WARNING_POP + // For the purpose of this test only, add (and then remove) the + // specific CA certificate. + const auto defaultConfig = QSslConfiguration::defaultConfiguration(); + auto temporaryDefault = defaultConfig; + temporaryDefault.addCaCertificate(caCerts.first()); + QSslConfiguration::setDefaultConfiguration(temporaryDefault); + const auto confGuard = qScopeGuard([&defaultConfig](){ + QSslConfiguration::setDefaultConfiguration(defaultConfig); + }); toVerify = QSslCertificate::fromPath(testDataDir + "verify-certs/test-ocsp-good-cert.pem", QSsl::Pem, QSslCertificate::PatternSyntax::FixedString); |