From 8ce93376cd6aa1fac0eeacbd804bc211b0814c91 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 28 Oct 2014 16:56:05 +0100 Subject: OS X and iOS: Search for openssl libs in .app/Contents/Frameworks This allows apps to ship their own openssl libraries inside the application bundle. The change consists of two parts: First, adding /Contents/Frameworks to the alternative search paths. Second, disabling the preemtive check for libssl.dylib, libcrypto.dylib in the system paths: The system's /usr/lib/libssl.dylib, /usr/lib/libcrypto.dylib will still be picked up as a fallback in the alternative search paths, but only after .app/Contents/Frameworks have been inspected. [ChangeLog][QtNetwork][QSsl] On OS X and iOS, openssl dylib's are picked up from the 'Frameworks' directory of the app bundle. Change-Id: I982930f4a6cf5e0114c04ecbc87f27e54ba8bb88 Reviewed-by: Jake Petroules --- src/network/ssl/qsslsocket_openssl_symbols.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/network') diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index f4562cdb21..71b8237e03 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -63,6 +63,9 @@ #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) #include #endif +#ifdef Q_OS_DARWIN +#include "private/qcore_mac_p.h" +#endif #include @@ -452,6 +455,15 @@ static QStringList libraryPathList() # ifdef Q_OS_DARWIN paths = QString::fromLatin1(qgetenv("DYLD_LIBRARY_PATH")) .split(QLatin1Char(':'), QString::SkipEmptyParts); + + // search in .app/Contents/Frameworks + UInt32 packageType; + CFBundleGetPackageInfo(CFBundleGetMainBundle(), &packageType, NULL); + if (packageType == FOUR_CHAR_CODE('APPL')) { + QUrl bundleUrl = QUrl::fromCFURL(QCFType(CFBundleCopyBundleURL(CFBundleGetMainBundle()))); + QUrl frameworksUrl = QUrl::fromCFURL(QCFType(CFBundleCopyPrivateFrameworksURL(CFBundleGetMainBundle()))); + paths << bundleUrl.resolved(frameworksUrl).path(); + } # else paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH")) .split(QLatin1Char(':'), QString::SkipEmptyParts); @@ -601,7 +613,13 @@ static QPair loadOpenSsl() } #endif +#ifndef Q_OS_DARWIN // second attempt: find the development files libssl.so and libcrypto.so + // + // disabled on OS X/iOS: + // OS X's /usr/lib/libssl.dylib, /usr/lib/libcrypto.dylib will be picked up in the third + // attempt, _after_ /Contents/Frameworks has been searched. + // iOS does not ship a system libssl.dylib, libcrypto.dylib in the first place. libssl->setFileNameAndVersion(QLatin1String("ssl"), -1); libcrypto->setFileNameAndVersion(QLatin1String("crypto"), -1); if (libcrypto->load() && libssl->load()) { @@ -611,6 +629,7 @@ static QPair loadOpenSsl() libssl->unload(); libcrypto->unload(); } +#endif // third attempt: loop on the most common library paths and find libssl QStringList sslList = findAllLibSsl(); -- cgit v1.2.3