Dynamically linked openssl not supported on iphonesimulator?
-
Hi
I've successfully built an app on iphonesimulator but openssl isn't supported, despite being linked dynamically.
QSslSocket::supportsSsl() returns false
QSslSocket::sslLibraryBuildVersionString() returns "OpenSSL 1.1.1c 28 May 2019"
QSslSocket::sslLibraryVersionString() returns empty stringoutput from .pro file:
LIBS=-L/Users/martin/workspace/qt_local_build/openssl_ios_x86_64_build/openssl-1.1.1c -lcrypto -lssl /Users/martin/workspace/qt_local_build/sqlcipher_ios_x86_64/sqlcipher/sqlite3.ooutput from otool -L:
/Users/martin/workspace/qt_local_build/openssl_ios_x86_64_build/openssl-1.1.1c/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/Users/martin/workspace/qt_local_build/openssl_ios_x86_64_build/openssl-1.1.1c/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)The same version of OpenSSL is working on other platforms albeit linked statically rather than dynamically.
macOS Catalina 10.15.7
iOS 14.2
darwin 19.6.0
Qt 5.12.11
Xcode 12.2
Qt Creator 4.13.3Am I doing something fundamentally wrong?
Any clues as to how to investigate this further? -
Fixed:
install_name_tool -id "@rpath/libssl.dylib" libssl.1.1.dylib install_name_tool -id "@rpath/libcrypto.dylib" libcrypto.1.1.dylib install_name_tool -change /Users/martin/workspace/qt_local_build/openssl_ios_x86_64_build/openssl-1.1.1c/lib/libcrypto.1.1.dylib "@rpath/libcrypto.dylib" libssl.1.1.dylib
and then these lines in the .pro file:
QMAKE_RPATHDIR = @executable_path/Frameworks crypto.files = "$${OPENSSL_DIR}/libcrypto$${DYNAMIC_LIB_EXT}" crypto.path = Frameworks QMAKE_BUNDLE_DATA += crypto ssl.files = "$${OPENSSL_DIR}/libssl$${DYNAMIC_LIB_EXT}" ssl.path = Frameworks QMAKE_BUNDLE_DATA += ssl
I had to apply a similar fix for the device. Here the app was crashing on startup because the libraries couldn't be loaded.
The next step will be to automate this in my build script.
-
As a postscript, it's worth noting that whilst this is fine for running an app in the simulator or on a development device, the Apple Store won't accept random libraries in the Frameworks folder, with the unhelpful message:
ITMS-90426: Invalid Swift Support* - The SwiftSupport folder is missing. Rebuild your app using the current public (GM) version of Xcode and resubmit it.
So you need either to link openssl statically or embed it in a Framework. I'm doing the former.
-
Hi and thanks for the feedback !
Out of curiosity, why not use the default backend for iOS that uses the native framework ?
-
There's nothing to setup, that's the default build.