summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/ssl/shared/qopenssl_symbols.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/network/ssl/shared/qopenssl_symbols.h')
-rw-r--r--tests/auto/network/ssl/shared/qopenssl_symbols.h108
1 files changed, 36 insertions, 72 deletions
diff --git a/tests/auto/network/ssl/shared/qopenssl_symbols.h b/tests/auto/network/ssl/shared/qopenssl_symbols.h
index 2c86f6e052..c98e90d424 100644
--- a/tests/auto/network/ssl/shared/qopenssl_symbols.h
+++ b/tests/auto/network/ssl/shared/qopenssl_symbols.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// Copyright (C) 2014 BlackBerry Limited. All rights reserved.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
/****************************************************************************
**
@@ -71,6 +35,7 @@
// reduced to the needs of our auto-tests, that have to mess with
// OpenSSL calls directly.
+#include <QtCore/qset.h>
#include <QtNetwork/private/qtnetworkglobal_p.h>
QT_REQUIRE_CONFIG(openssl);
@@ -206,43 +171,40 @@ void qsslSocketCannotResolveSymbolWarning(const char *functionName)
#define DUMMYARG
-#define FUNC_UNUSED(func) \
- []() {Q_UNUSED(q_##func);}()
-
#if defined(QT_LINKED_OPENSSL)
// **************** Static declarations ******************
// ret func(arg)
# define DEFINEFUNC(ret, func, arg, a, err, funcret) \
- ret q_##func(arg) { FUNC_UNUSED(func); funcret func(a); }
+ [[maybe_unused]] ret q_##func(arg) { funcret func(a); }
// ret func(arg1, arg2)
# define DEFINEFUNC2(ret, func, arg1, a, arg2, b, err, funcret) \
- ret q_##func(arg1, arg2) { FUNC_UNUSED(func); funcret func(a, b); }
+ [[maybe_unused]] ret q_##func(arg1, arg2) { funcret func(a, b); }
// ret func(arg1, arg2, arg3)
# define DEFINEFUNC3(ret, func, arg1, a, arg2, b, arg3, c, err, funcret) \
- ret q_##func(arg1, arg2, arg3) { FUNC_UNUSED(func); funcret func(a, b, c); }
+ [[maybe_unused]] ret q_##func(arg1, arg2, arg3) { funcret func(a, b, c); }
// ret func(arg1, arg2, arg3, arg4)
# define DEFINEFUNC4(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, err, funcret) \
- ret q_##func(arg1, arg2, arg3, arg4) { FUNC_UNUSED(func); funcret func(a, b, c, d); }
+ [[maybe_unused]] ret q_##func(arg1, arg2, arg3, arg4) { funcret func(a, b, c, d); }
// ret func(arg1, arg2, arg3, arg4, arg5)
# define DEFINEFUNC5(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, err, funcret) \
- ret q_##func(arg1, arg2, arg3, arg4, arg5) { FUNC_UNUSED(func); funcret func(a, b, c, d, e); }
+ [[maybe_unused]] ret q_##func(arg1, arg2, arg3, arg4, arg5) { funcret func(a, b, c, d, e); }
// ret func(arg1, arg2, arg3, arg4, arg6)
# define DEFINEFUNC6(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, err, funcret) \
- ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6) { FUNC_UNUSED(func); funcret func(a, b, c, d, e, f); }
+ [[maybe_unused]] ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6) { funcret func(a, b, c, d, e, f); }
// ret func(arg1, arg2, arg3, arg4, arg6, arg7)
# define DEFINEFUNC7(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, err, funcret) \
- ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { FUNC_UNUSED(func); funcret func(a, b, c, d, e, f, g); }
+ [[maybe_unused]] ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { funcret func(a, b, c, d, e, f, g); }
// ret func(arg1, arg2, arg3, arg4, arg6, arg7, arg8, arg9)
# define DEFINEFUNC9(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, arg8, h, arg9, i, err, funcret) \
- ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { FUNC_UNUSED(func); funcret func(a, b, c, d, e, f, g, h, i); }
+ [[maybe_unused]] ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { funcret func(a, b, c, d, e, f, g, h, i); }
// **************** Static declarations ******************
@@ -254,8 +216,7 @@ void qsslSocketCannotResolveSymbolWarning(const char *functionName)
# define DEFINEFUNC(ret, func, arg, a, err, funcret) \
typedef ret (*_q_PTR_##func)(arg); \
static _q_PTR_##func _q_##func = 0; \
- ret q_##func(arg) { \
- FUNC_UNUSED(func); \
+ [[maybe_unused]] ret q_##func(arg) { \
if (Q_UNLIKELY(!_q_##func)) { \
qsslSocketUnresolvedSymbolWarning(#func); \
err; \
@@ -267,8 +228,7 @@ void qsslSocketCannotResolveSymbolWarning(const char *functionName)
# define DEFINEFUNC2(ret, func, arg1, a, arg2, b, err, funcret) \
typedef ret (*_q_PTR_##func)(arg1, arg2); \
static _q_PTR_##func _q_##func = 0; \
- ret q_##func(arg1, arg2) { \
- FUNC_UNUSED(func); \
+ [[maybe_unused]] ret q_##func(arg1, arg2) { \
if (Q_UNLIKELY(!_q_##func)) { \
qsslSocketUnresolvedSymbolWarning(#func);\
err; \
@@ -280,8 +240,7 @@ void qsslSocketCannotResolveSymbolWarning(const char *functionName)
# define DEFINEFUNC3(ret, func, arg1, a, arg2, b, arg3, c, err, funcret) \
typedef ret (*_q_PTR_##func)(arg1, arg2, arg3); \
static _q_PTR_##func _q_##func = 0; \
- ret q_##func(arg1, arg2, arg3) { \
- FUNC_UNUSED(func); \
+ [[maybe_unused]] ret q_##func(arg1, arg2, arg3) { \
if (Q_UNLIKELY(!_q_##func)) { \
qsslSocketUnresolvedSymbolWarning(#func); \
err; \
@@ -293,8 +252,7 @@ void qsslSocketCannotResolveSymbolWarning(const char *functionName)
# define DEFINEFUNC4(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, err, funcret) \
typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4); \
static _q_PTR_##func _q_##func = 0; \
- ret q_##func(arg1, arg2, arg3, arg4) { \
- FUNC_UNUSED(func); \
+ [[maybe_unused]] ret q_##func(arg1, arg2, arg3, arg4) { \
if (Q_UNLIKELY(!_q_##func)) { \
qsslSocketUnresolvedSymbolWarning(#func); \
err; \
@@ -306,8 +264,7 @@ void qsslSocketCannotResolveSymbolWarning(const char *functionName)
# define DEFINEFUNC5(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, err, funcret) \
typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5); \
static _q_PTR_##func _q_##func = 0; \
- ret q_##func(arg1, arg2, arg3, arg4, arg5) { \
- FUNC_UNUSED(func); \
+ [[maybe_unused]] ret q_##func(arg1, arg2, arg3, arg4, arg5) { \
if (Q_UNLIKELY(!_q_##func)) { \
qsslSocketUnresolvedSymbolWarning(#func); \
err; \
@@ -319,8 +276,7 @@ void qsslSocketCannotResolveSymbolWarning(const char *functionName)
# define DEFINEFUNC6(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, err, funcret) \
typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6); \
static _q_PTR_##func _q_##func = 0; \
- ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6) { \
- FUNC_UNUSED(func); \
+ [[maybe_unused]] ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6) { \
if (Q_UNLIKELY(!_q_##func)) { \
qsslSocketUnresolvedSymbolWarning(#func); \
err; \
@@ -332,8 +288,7 @@ void qsslSocketCannotResolveSymbolWarning(const char *functionName)
# define DEFINEFUNC7(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, err, funcret) \
typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
static _q_PTR_##func _q_##func = 0; \
- ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { \
- FUNC_UNUSED(func); \
+ [[maybe_unused]] ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { \
if (Q_UNLIKELY(!_q_##func)) { \
qsslSocketUnresolvedSymbolWarning(#func); \
err; \
@@ -345,8 +300,7 @@ void qsslSocketCannotResolveSymbolWarning(const char *functionName)
# define DEFINEFUNC9(ret, func, arg1, a, arg2, b, arg3, c, arg4, d, arg5, e, arg6, f, arg7, g, arg8, h, arg9, i, err, funcret) \
typedef ret (*_q_PTR_##func)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \
static _q_PTR_##func _q_##func = 0; \
- ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { \
- FUNC_UNUSED(func); \
+ [[maybe_unused]] ret q_##func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) { \
if (Q_UNLIKELY(!_q_##func)) { \
qsslSocketUnresolvedSymbolWarning(#func); \
err; \
@@ -410,8 +364,6 @@ DEFINEFUNC(void, OCSP_CERTID_free, OCSP_CERTID *cid, cid, return, DUMMYARG)
#endif // QT_CONFIG(ocsp)
-#undef FUNC_UNUSED
-
#ifndef QT_LINKED_OPENSSL
#if !QT_CONFIG(library)
@@ -453,7 +405,7 @@ struct LibGreaterThan
{
const auto lhsparts = lhs.split(QLatin1Char('.'));
const auto rhsparts = rhs.split(QLatin1Char('.'));
- Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1);
+ Q_ASSERT(lhsparts.size() > 1 && rhsparts.size() > 1);
// note: checking rhs < lhs, the same as lhs > rhs
return std::lexicographical_compare(rhsparts.begin() + 1, rhsparts.end(),
@@ -529,7 +481,7 @@ QStringList findAllLibs(QLatin1String filter)
QStringList entryList = dir.entryList(filters, QDir::Files);
std::sort(entryList.begin(), entryList.end(), LibGreaterThan());
- for (const QString &entry : qAsConst(entryList))
+ for (const QString &entry : std::as_const(entryList))
found << path + QLatin1Char('/') + entry;
}
@@ -550,6 +502,12 @@ QStringList findAllLibCrypto()
#ifdef Q_OS_WIN
+#if (OPENSSL_VERSION_NUMBER >> 28) < 3
+#define QT_OPENSSL_VERSION "1_1"
+#elif OPENSSL_VERSION_MAJOR == 3 // Starting with 3.0 this define is available
+#define QT_OPENSSL_VERSION "3"
+#endif // > 3 intentionally left undefined
+
struct LoadedOpenSsl {
std::unique_ptr<QSystemLibrary> ssl, crypto;
};
@@ -588,8 +546,9 @@ static LoadedOpenSsl loadOpenSsl()
#define QT_SSL_SUFFIX
#endif
- tryToLoadOpenSslWin32Library(QLatin1String("libssl-1_1" QT_SSL_SUFFIX),
- QLatin1String("libcrypto-1_1" QT_SSL_SUFFIX), result);
+ tryToLoadOpenSslWin32Library(QLatin1String("libssl-" QT_OPENSSL_VERSION QT_SSL_SUFFIX),
+ QLatin1String("libcrypto-" QT_OPENSSL_VERSION QT_SSL_SUFFIX),
+ result);
#undef QT_SSL_SUFFIX
return result;
@@ -698,6 +657,11 @@ LoadedOpenSsl loadOpenSsl()
const QStringList cryptoList = findAllLibCrypto();
for (const QString &crypto : cryptoList) {
+#ifdef Q_OS_DARWIN
+ // Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI
+ if (crypto.endsWith("libcrypto.dylib"))
+ continue;
+#endif
libcrypto->setFileNameAndVersion(crypto, -1);
if (libcrypto->load()) {
QFileInfo fi(crypto);