A follow-up fix for potentially missing OpenSSL symbol resolving

This patch also adds 'isValid()' to know if a backend from a plugin
is in working condition (say, there is 'openssl' plugin but no or
old openssl libraries in some system).

Pick-to: dev
Task-number: QTBUG-65922
Change-Id: I0b846536a069ca8c5a94e7191f11c81bac6ad527
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Timur Pocheptsov 2021-02-19 15:52:36 +01:00
parent 64c47d7f61
commit 573ba145d7
5 changed files with 28 additions and 2 deletions

View File

@ -2844,6 +2844,11 @@ QTlsBackend *QSslSocketPrivate::tlsBackendInUse()
if (!activeBackendName.size())
activeBackendName = QTlsBackend::defaultBackendName();
if (!activeBackendName.size()) {
qCWarning(lcSsl, "No functional TLS backend was found");
return nullptr;
}
return tlsBackend = QTlsBackend::findBackend(activeBackendName);
}

View File

@ -110,8 +110,10 @@ public:
return names;
names.reserve(backends.size());
for (const auto *factory : backends)
names.append(factory->backendName());
for (const auto *backend : backends) {
if (backend->isValid())
names.append(backend->backendName());
}
return names;
}
@ -198,6 +200,11 @@ QTlsBackend::~QTlsBackend()
backends->removeBackend(this);
}
bool QTlsBackend::isValid() const
{
return true;
}
QString QTlsBackend::backendName() const
{
return QStringLiteral("dummyTLS");

View File

@ -41,6 +41,10 @@
#include "qtlskey_openssl_p.h"
#include "qx509_openssl_p.h"
// TLSTODO: Later, this code (ensure initialised, etc.)
// must move from the socket to backend.
#include "qsslsocket_p.h"
//
#include "qsslsocket_openssl_symbols_p.h"
#include <qssl.h>
@ -83,6 +87,13 @@ QString QTlsBackendOpenSSL::backendName() const
return builtinBackendNames[nameIndexOpenSSL];
}
bool QTlsBackendOpenSSL::isValid() const
{
// TLSTODO: backend should do initialization,
// not socket.
return QSslSocket::supportsSsl();
}
QList<QSsl::SslProtocol> QTlsBackendOpenSSL::supportedProtocols() const
{
QList<QSsl::SslProtocol> protocols;

View File

@ -68,6 +68,7 @@ public:
static void clearErrorQueue();
private:
QString backendName() const override;
bool isValid() const override;
QList<QSsl::SslProtocol> supportedProtocols() const override;
QList<QSsl::SupportedFeature> supportedFeatures() const override;

View File

@ -195,6 +195,8 @@ public:
QTlsBackend();
~QTlsBackend() override;
virtual bool isValid() const;
virtual QString backendName() const = 0;
virtual QList<QSsl::SslProtocol> supportedProtocols() const = 0;
virtual QList<QSsl::SupportedFeature> supportedFeatures() const = 0;