Browse Source

QGeoMapReplyQGC: ignore SSL without OpenSSL 1.x

This fixes terrain download on Ubuntu 22.04 where only OpenSSL 3 is
available on the system but Qt5 wants OpenSSL 1.x.

This just copies the fix over from QGCFileDownload.
QGC4.4
Julian Oes 9 months ago
parent
commit
4b50ece3d8
No known key found for this signature in database
GPG Key ID: F0ED380FEA56DE41
  1. 20
      src/QtLocationPlugin/QGeoMapReplyQGC.cpp
  2. 1
      src/QtLocationPlugin/QGeoMapReplyQGC.h

20
src/QtLocationPlugin/QGeoMapReplyQGC.cpp

@ -209,6 +209,9 @@ QGeoTiledMapReplyQGC::cacheError(QGCMapTask::TaskType type, QString /*errorStrin
#endif #endif
_reply = _networkManager->get(_request); _reply = _networkManager->get(_request);
_reply->setParent(nullptr); _reply->setParent(nullptr);
setIgnoreSSLErrorsIfNeeded(*_reply);
connect(_reply, &QNetworkReply::finished, this, &QGeoTiledMapReplyQGC::networkReplyFinished); connect(_reply, &QNetworkReply::finished, this, &QGeoTiledMapReplyQGC::networkReplyFinished);
connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkReplyError(QNetworkReply::NetworkError))); connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkReplyError(QNetworkReply::NetworkError)));
#if !defined(__mobile__) #if !defined(__mobile__)
@ -248,3 +251,20 @@ QGeoTiledMapReplyQGC::timeout()
} }
emit aborted(); emit aborted();
} }
//-----------------------------------------------------------------------------
void QGeoTiledMapReplyQGC::setIgnoreSSLErrorsIfNeeded(QNetworkReply& networkReply)
{
// Some systems (like Ubuntu 22.04) only ship with OpenSSL 3.x, however Qt 5.15.2 links against OpenSSL 1.x.
// This results in unresolved symbols for EVP_PKEY_base_id and SSL_get_peer_certificate.
// To still get a connection we have to ignore certificate verification (connection is still encrypted but open to MITM attacks)
// See https://bugreports.qt.io/browse/QTBUG-115146
const bool sslLibraryBuildIs1x = (QSslSocket::sslLibraryBuildVersionNumber() & 0xf0000000) == 0x10000000;
const bool sslLibraryIs3x = (QSslSocket::sslLibraryVersionNumber() & 0xf0000000) == 0x30000000;
if (sslLibraryBuildIs1x && sslLibraryIs3x) {
qWarning() << "Ignoring ssl certificates due to OpenSSL version mismatch";
QList<QSslError> errorsThatCanBeIgnored;
errorsThatCanBeIgnored << QSslError(QSslError::NoPeerCertificate);
networkReply.ignoreSslErrors(errorsThatCanBeIgnored);
}
}

1
src/QtLocationPlugin/QGeoMapReplyQGC.h

@ -73,6 +73,7 @@ private slots:
private: private:
void _clearReply (); void _clearReply ();
void setIgnoreSSLErrorsIfNeeded(QNetworkReply& networkReply);
private: private:
QNetworkReply* _reply; QNetworkReply* _reply;

Loading…
Cancel
Save