Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt5 has no SSL/TLS support #93

Closed
TeLLie opened this issue Jul 13, 2019 · 3 comments
Closed

Qt5 has no SSL/TLS support #93

TeLLie opened this issue Jul 13, 2019 · 3 comments
Assignees
Labels
QtNetwork Tickets belonging to QtNetwork module

Comments

@TeLLie
Copy link

TeLLie commented Jul 13, 2019

When running the examples from the QT5 ports, i notice that there is no support for SSL/TLS

F:\Qt5-OS2\examples\network\http\release>http.exe
qt.network.ssl: QSslSocket: cannot call unresolved function SSLv23_client_method
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_CTX_new
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_library_init
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error

It says we don't have SSL/TLS support (edited)

@SilvanScherrer
Copy link
Contributor

SilvanScherrer commented Jul 15, 2019

this path fixes the ssl issue

diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index 82ff5e9e..08cb7ab4 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -65,7 +65,7 @@
 #include <QtCore/qmutex.h>
 #include <private/qmutexpool_p.h>
 #include <QtCore/qdatetime.h>
-#if defined(Q_OS_UNIX)
+#if defined(Q_OS_UNIXLIKE)
 #include <QtCore/qdir.h>
 #endif
 #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
@@ -541,10 +541,17 @@ DEFINEFUNC5(int, PKCS12_parse, PKCS12 *p12, p12, const char *pass, pass, EVP_PKE
 DEFINEFUNC2(PKCS12 *, d2i_PKCS12_bio, BIO *bio, bio, PKCS12 **pkcs12, pkcs12, return 0, return);
 DEFINEFUNC(void, PKCS12_free, PKCS12 *pkcs12, pkcs12, return, DUMMYARG)
 
+#ifdef Q_OS_OS2
+#define RESOLVEFUNC(func) \
+    if (!(_q_##func = _q_PTR_##func(libs.first->resolve("_"#func)))     \
+        && !(_q_##func = _q_PTR_##func(libs.second->resolve("_"#func)))) \
+        qsslSocketCannotResolveSymbolWarning(#func);
+#else
 #define RESOLVEFUNC(func) \
     if (!(_q_##func = _q_PTR_##func(libs.first->resolve(#func)))     \
         && !(_q_##func = _q_PTR_##func(libs.second->resolve(#func)))) \
         qsslSocketCannotResolveSymbolWarning(#func);
+#endif
 
 #if !defined QT_LINKED_OPENSSL
 
@@ -559,7 +566,7 @@ bool q_resolveOpenSslSymbols()
 }
 #else
 
-# ifdef Q_OS_UNIX
+# if defined(Q_OS_UNIXLIKE)
 struct NumericallyLess
 {
     typedef bool result_type;
@@ -632,6 +639,9 @@ static QStringList libraryPathList()
     paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH"))
             .split(QLatin1Char(':'), QString::SkipEmptyParts);
 #  endif
+#ifdef Q_OS_OS2
+    paths << QLatin1String("/@unixroot/usr/lib") << QLatin1String("/@unixroot/usr/local/lib");
+#endif
     paths << QLatin1String("/lib") << QLatin1String("/usr/lib") << QLatin1String("/usr/local/lib");
     paths << QLatin1String("/lib64") << QLatin1String("/usr/lib64") << QLatin1String("/usr/local/lib64");
     paths << QLatin1String("/lib32") << QLatin1String("/usr/lib32") << QLatin1String("/usr/local/lib32");
@@ -669,12 +679,20 @@ static QStringList findAllLibs(QLatin1String filter)
 
 static QStringList findAllLibSsl()
 {
+#ifdef Q_OS_OS2
+    return findAllLibs(QLatin1String("ssl*.dll"));
+#else
     return findAllLibs(QLatin1String("libssl.*"));
+#endif
 }
 
 static QStringList findAllLibCrypto()
 {
+#ifdef Q_OS_OS2
+    return findAllLibs(QLatin1String("crypto*.dll"));
+#else
     return findAllLibs(QLatin1String("libcrypto.*"));
+#endif
 }
 # endif
 
@@ -745,7 +763,7 @@ static QPair<QLibrary*, QLibrary*> loadOpenSsl()
 {
     QPair<QLibrary*,QLibrary*> pair;
 
-# if defined(Q_OS_UNIX)
+# if defined(Q_OS_UNIXLIKE)
     QLibrary *&libssl = pair.first;
     QLibrary *&libcrypto = pair.second;
     libssl = new QLibrary;

but when using the debug build I get the following afterwards:
[E:\trees\qt5\dev-build\qtbase\lib]..\examples\network\http\debug\http
ASSERT: "timeout" in file E:/Trees/qt5/git/qtbase/src/corelib/kernel/qeventdispatcher_os2.cpp, line 585

Killed by SIGABRT
pid=0x9bbf ppid=0x5d74 tid=0x0007 slot=0x00cb pri=0x0200 mc=0x0001 ps=0x0010
E:\TREES\QT5\DEV-BUILD\QTBASE\EXAMPLES\NETWORK\HTTP\DEBUG\HTTP.EXE
Process dumping was disabled, use DUMPPROC / PROCDUMP to enable it.

@dmik
Copy link
Contributor

dmik commented Jul 16, 2019

BTW, there is a configure option to link to OpenSSL DLLs statically instead of this dynamic linking: -openssl-linked. Technically, this makes the patch above unneeded but it makes sense to keep it anyway to have a choice once we need that.

@dmik dmik added this to To do in [Qt 5] 1.4. Port Qt Network via automation Jul 16, 2019
@dmik dmik added the QtNetwork Tickets belonging to QtNetwork module label Jul 16, 2019
@dmik dmik moved this from To do to In progress in [Qt 5] 1.4. Port Qt Network Jul 16, 2019
@dmik dmik self-assigned this Jul 16, 2019
dmik added a commit that referenced this issue Jul 17, 2019
@dmik
Copy link
Contributor

dmik commented Jul 17, 2019

@SilvanScherrer's patch committed (with slight modifications). I also tested -openssl-linked build mode. In both modes most SSL tests run fine now (see #74 for details). I consider this to be done. Note that we will stick with -openssl-linked for the time being — same as Fedora folks do. This means that Qt5Net.dll will be statically linked to ssl10.dl and crypto10.dll and will simply not load otherwise.

@dmik dmik closed this as completed Jul 17, 2019
[Qt 5] 1.4. Port Qt Network automation moved this from In progress to Done Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QtNetwork Tickets belonging to QtNetwork module
Development

No branches or pull requests

3 participants