summaryrefslogtreecommitdiffstats
path: root/src/network/ssl/qsslsocket_openssl_symbols.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/ssl/qsslsocket_openssl_symbols.cpp')
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp65
1 files changed, 53 insertions, 12 deletions
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index b5374d13cd..2e99bdbca4 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -125,6 +125,7 @@ DEFINEFUNC3(X509 *, d2i_X509, X509 **a, a, const unsigned char **b, b, long c, c
#endif
DEFINEFUNC2(char *, ERR_error_string, unsigned long a, a, char *b, b, return 0, return)
DEFINEFUNC(unsigned long, ERR_get_error, DUMMYARG, DUMMYARG, return 0, return)
+DEFINEFUNC(void, ERR_free_strings, void, DUMMYARG, return, DUMMYARG)
DEFINEFUNC(const EVP_CIPHER *, EVP_des_ede3_cbc, DUMMYARG, DUMMYARG, return 0, return)
DEFINEFUNC3(int, EVP_PKEY_assign, EVP_PKEY *a, a, int b, b, char *c, c, return -1, return)
DEFINEFUNC2(int, EVP_PKEY_set1_RSA, EVP_PKEY *a, a, RSA *b, b, return -1, return)
@@ -367,7 +368,7 @@ static int dlIterateCallback(struct dl_phdr_info *info, size_t size, void *data)
}
#endif
-static QStringList findAllLibSsl()
+static QStringList libraryPathList()
{
QStringList paths;
# ifdef Q_OS_DARWIN
@@ -378,6 +379,9 @@ static QStringList findAllLibSsl()
.split(QLatin1Char(':'), QString::SkipEmptyParts);
# 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");
+
#ifdef Q_OS_LINUX
// discover paths of already loaded libraries
QSet<QString> loadedPaths;
@@ -385,9 +389,17 @@ static QStringList findAllLibSsl()
paths.append(loadedPaths.toList());
#endif
+ return paths;
+}
+
+
+static QStringList findAllLibSsl()
+{
+ QStringList paths = libraryPathList();
QStringList foundSsls;
+
foreach (const QString &path, paths) {
- QDir dir = QDir(path);
+ QDir dir(path);
QStringList entryList = dir.entryList(QStringList() << QLatin1String("libssl.*"), QDir::Files);
qSort(entryList.begin(), entryList.end(), libGreaterThan);
@@ -397,6 +409,23 @@ static QStringList findAllLibSsl()
return foundSsls;
}
+
+static QStringList findAllLibCrypto()
+{
+ QStringList paths = libraryPathList();
+
+ QStringList foundCryptos;
+ foreach (const QString &path, paths) {
+ QDir dir(path);
+ QStringList entryList = dir.entryList(QStringList() << QLatin1String("libcrypto.*"), QDir::Files);
+
+ qSort(entryList.begin(), entryList.end(), libGreaterThan);
+ foreach (const QString &entry, entryList)
+ foundCryptos << path + QLatin1Char('/') + entry;
+ }
+
+ return foundCryptos;
+}
# endif
#ifdef Q_OS_WIN
@@ -489,18 +518,29 @@ static QPair<QLibrary*, QLibrary*> loadOpenSsl()
// third attempt: loop on the most common library paths and find libssl
QStringList sslList = findAllLibSsl();
- foreach (const QString &ssl, sslList) {
- QString crypto = ssl;
- crypto.replace(QLatin1String("ssl"), QLatin1String("crypto"));
- libssl->setFileNameAndVersion(ssl, -1);
+ QStringList cryptoList = findAllLibCrypto();
+
+ foreach (const QString &crypto, cryptoList) {
libcrypto->setFileNameAndVersion(crypto, -1);
- if (libcrypto->load() && libssl->load()) {
- // libssl.so.0 and libcrypto.so.0 found
- return pair;
- } else {
- libssl->unload();
- libcrypto->unload();
+ if (libcrypto->load()) {
+ QFileInfo fi(crypto);
+ QString version = fi.completeSuffix();
+
+ foreach (const QString &ssl, sslList) {
+ if (!ssl.endsWith(version))
+ continue;
+
+ libssl->setFileNameAndVersion(ssl, -1);
+
+ if (libssl->load()) {
+ // libssl.so.x and libcrypto.so.x found
+ return pair;
+ } else {
+ libssl->unload();
+ }
+ }
}
+ libcrypto->unload();
}
// failed to load anything
@@ -560,6 +600,7 @@ bool q_resolveOpenSslSymbols()
RESOLVEFUNC(DSA_free)
RESOLVEFUNC(ERR_error_string)
RESOLVEFUNC(ERR_get_error)
+ RESOLVEFUNC(ERR_free_strings)
RESOLVEFUNC(EVP_des_ede3_cbc)
RESOLVEFUNC(EVP_PKEY_assign)
RESOLVEFUNC(EVP_PKEY_set1_RSA)