remove code for non-OpenSSL linked build

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2016-01-11 00:21:23 +02:00
parent a66eaa8870
commit 2298738735
2 changed files with 0 additions and 537 deletions

View file

@ -287,440 +287,6 @@ DEFINEFUNC(void, OPENSSL_add_all_algorithms_conf, void, DUMMYARG, return, DUMMYA
DEFINEFUNC3(int, SSL_CTX_load_verify_locations, SSL_CTX *ctx, ctx, const char *CAfile, CAfile, const char *CApath, CApath, return 0, return)
DEFINEFUNC(long, SSLeay, void, DUMMYARG, return 0, return)
#define RESOLVEFUNC(func) \
if (!(_q_##func = _q_PTR_##func(libs.first->resolve(#func))) \
&& !(_q_##func = _q_PTR_##func(libs.second->resolve(#func)))) \
qWarning("QSslSocket: cannot resolve "#func);
#if !defined QT_LINKED_OPENSSL
#ifdef QT_NO_LIBRARY
bool q_resolveOpenSslSymbols()
{
qWarning("QSslSocket: unable to resolve symbols. "
"QT_NO_LIBRARY is defined which means runtime resolving of "
"libraries won't work.");
qWarning("Either compile Qt statically or with support for runtime resolving "
"of libraries.");
return false;
}
#else
# ifdef Q_OS_UNIX
static bool libGreaterThan(const QString &lhs, const QString &rhs)
{
QStringList lhsparts = lhs.split(QLatin1Char('.'));
QStringList rhsparts = rhs.split(QLatin1Char('.'));
Q_ASSERT(lhsparts.count() > 1 && rhsparts.count() > 1);
for (int i = 1; i < rhsparts.count(); ++i) {
if (lhsparts.count() <= i)
// left hand side is shorter, so it's less than rhs
return false;
bool ok = false;
int b = 0;
int a = lhsparts.at(i).toInt(&ok);
if (ok)
b = rhsparts.at(i).toInt(&ok);
if (ok) {
// both toInt succeeded
if (a == b)
continue;
return a > b;
} else {
// compare as strings;
if (lhsparts.at(i) == rhsparts.at(i))
continue;
return lhsparts.at(i) > rhsparts.at(i);
}
}
// they compared strictly equally so far
// lhs cannot be less than rhs
return true;
}
#ifdef Q_OS_LINUX
static int dlIterateCallback(struct dl_phdr_info *info, size_t size, void *data)
{
if (size < sizeof (info->dlpi_addr) + sizeof (info->dlpi_name))
return 1;
QSet<QString> *paths = (QSet<QString> *)data;
QString path = QString::fromLocal8Bit(info->dlpi_name);
if (!path.isEmpty()) {
QFileInfo fi(path);
path = fi.absolutePath();
if (!path.isEmpty())
paths->insert(path);
}
return 0;
}
#endif
static QStringList libraryPathList()
{
QStringList paths;
# ifdef Q_OS_DARWIN
paths = QString::fromLatin1(qgetenv("DYLD_LIBRARY_PATH"))
.split(QLatin1Char(':'), QString::SkipEmptyParts);
# else
paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH"))
.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;
dl_iterate_phdr(dlIterateCallback, &loadedPaths);
paths.append(loadedPaths.toList());
#endif
return paths;
}
static QStringList findAllLibSsl()
{
QStringList paths = libraryPathList();
QStringList foundSsls;
foreach (const QString &path, paths) {
QDir dir(path);
QStringList entryList = dir.entryList(QStringList() << QLatin1String("libssl.*"), QDir::Files);
qSort(entryList.begin(), entryList.end(), libGreaterThan);
foreach (const QString &entry, entryList)
foundSsls << path + QLatin1Char('/') + entry;
}
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
static QPair<QSystemLibrary*, QSystemLibrary*> loadOpenSslWin32()
{
QPair<QSystemLibrary*,QSystemLibrary*> pair;
pair.first = 0;
pair.second = 0;
QSystemLibrary *ssleay32 = new QSystemLibrary(QLatin1String("ssleay32"));
if (!ssleay32->load(false)) {
// Cannot find ssleay32.dll
delete ssleay32;
return pair;
}
QSystemLibrary *libeay32 = new QSystemLibrary(QLatin1String("libeay32"));
if (!libeay32->load(false)) {
delete ssleay32;
delete libeay32;
return pair;
}
pair.first = ssleay32;
pair.second = libeay32;
return pair;
}
#else
static QPair<QLibrary*, QLibrary*> loadOpenSsl()
{
QPair<QLibrary*,QLibrary*> pair;
pair.first = 0;
pair.second = 0;
# if defined(Q_OS_UNIX)
QLibrary *&libssl = pair.first;
QLibrary *&libcrypto = pair.second;
libssl = new QLibrary;
libcrypto = new QLibrary;
// Try to find the libssl library on the system.
//
// Up until Qt 4.3, this only searched for the "ssl" library at version -1, that
// is, libssl.so on most Unix systems. However, the .so file isn't present in
// user installations because it's considered a development file.
//
// The right thing to do is to load the library at the major version we know how
// to work with: the SHLIB_VERSION_NUMBER version (macro defined in opensslv.h)
//
// However, OpenSSL is a well-known case of binary-compatibility breakage. To
// avoid such problems, many system integrators and Linux distributions change
// the soname of the binary, letting the full version number be the soname. So
// we'll find libssl.so.0.9.7, libssl.so.0.9.8, etc. in the system. For that
// reason, we will search a few common paths (see findAllLibSsl() above) in hopes
// we find one that works.
//
// It is important, however, to try the canonical name and the unversioned name
// without going through the loop. By not specifying a path, we let the system
// dlopen(3) function determine it for us. This will include any DT_RUNPATH or
// DT_RPATH tags on our library header as well as other system-specific search
// paths. See the man page for dlopen(3) on your system for more information.
#ifdef Q_OS_OPENBSD
libcrypto->setLoadHints(QLibrary::ExportExternalSymbolsHint);
#endif
#if defined(Q_OS_QNX) // on QNX, the libs are always libssl.so and libcrypto.so
libssl->setLoadHints(QLibrary::ImprovedSearchHeuristics);
libcrypto->setLoadHints(libcrypto->loadHints() | QLibrary::ImprovedSearchHeuristics);
#elif defined(SHLIB_VERSION_NUMBER)
// first attempt: the canonical name is libssl.so.<SHLIB_VERSION_NUMBER>
libssl->setFileNameAndVersion(QLatin1String("ssl"), QLatin1String(SHLIB_VERSION_NUMBER));
libssl->setLoadHints(QLibrary::ImprovedSearchHeuristics);
libcrypto->setFileNameAndVersion(QLatin1String("crypto"), QLatin1String(SHLIB_VERSION_NUMBER));
libcrypto->setLoadHints(libcrypto->loadHints() | QLibrary::ImprovedSearchHeuristics);
if (libcrypto->load() && libssl->load()) {
// libssl.so.<SHLIB_VERSION_NUMBER> and libcrypto.so.<SHLIB_VERSION_NUMBER> found
return pair;
} else {
libssl->unload();
libcrypto->unload();
}
#endif
// second attempt: find the development files libssl.so and libcrypto.so
libssl->setFileNameAndVersion(QLatin1String("ssl"), -1);
libcrypto->setFileNameAndVersion(QLatin1String("crypto"), -1);
if (libcrypto->load() && libssl->load()) {
// libssl.so.0 and libcrypto.so.0 found
return pair;
} else {
libssl->unload();
libcrypto->unload();
}
// third attempt: loop on the most common library paths and find libssl
QStringList sslList = findAllLibSsl();
QStringList cryptoList = findAllLibCrypto();
foreach (const QString &crypto, cryptoList) {
libcrypto->setFileNameAndVersion(crypto, -1);
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
delete libssl;
delete libcrypto;
libssl = libcrypto = 0;
return pair;
# else
// not implemented for this platform yet
return pair;
# endif
}
#endif
bool q_resolveOpenSslSymbols()
{
static volatile bool symbolsResolved = false;
static volatile bool triedToResolveSymbols = false;
#ifndef QT_NO_THREAD
QMutexLocker locker(QMutexPool::globalInstanceGet((void *)&q_SSL_library_init));
#endif
if (symbolsResolved)
return true;
if (triedToResolveSymbols)
return false;
triedToResolveSymbols = true;
#ifdef Q_OS_WIN
QPair<QSystemLibrary *, QSystemLibrary *> libs = loadOpenSslWin32();
#else
QPair<QLibrary *, QLibrary *> libs = loadOpenSsl();
#endif
if (!libs.first || !libs.second)
// failed to load them
return false;
#ifdef SSLEAY_MACROS
RESOLVEFUNC(ASN1_dup)
#endif
RESOLVEFUNC(ASN1_INTEGER_get)
RESOLVEFUNC(ASN1_STRING_data)
RESOLVEFUNC(ASN1_STRING_length)
RESOLVEFUNC(ASN1_STRING_to_UTF8)
RESOLVEFUNC(BIO_ctrl)
RESOLVEFUNC(BIO_free)
RESOLVEFUNC(BIO_new)
RESOLVEFUNC(BIO_new_mem_buf)
RESOLVEFUNC(BIO_read)
RESOLVEFUNC(BIO_s_mem)
RESOLVEFUNC(BIO_write)
RESOLVEFUNC(BN_num_bits)
RESOLVEFUNC(CRYPTO_free)
RESOLVEFUNC(CRYPTO_num_locks)
RESOLVEFUNC(CRYPTO_set_id_callback)
RESOLVEFUNC(CRYPTO_set_locking_callback)
RESOLVEFUNC(DSA_free)
RESOLVEFUNC(ERR_error_string)
RESOLVEFUNC(ERR_get_error)
RESOLVEFUNC(EVP_des_ede3_cbc)
RESOLVEFUNC(EVP_PKEY_assign)
RESOLVEFUNC(EVP_PKEY_set1_RSA)
RESOLVEFUNC(EVP_PKEY_set1_DSA)
RESOLVEFUNC(EVP_PKEY_free)
RESOLVEFUNC(EVP_PKEY_get1_DSA)
RESOLVEFUNC(EVP_PKEY_get1_RSA)
RESOLVEFUNC(EVP_PKEY_new)
RESOLVEFUNC(EVP_PKEY_type)
RESOLVEFUNC(OBJ_nid2sn)
RESOLVEFUNC(OBJ_obj2nid)
#ifdef SSLEAY_MACROS // ### verify
RESOLVEFUNC(PEM_ASN1_read_bio)
#else
RESOLVEFUNC(PEM_read_bio_DSAPrivateKey)
RESOLVEFUNC(PEM_read_bio_RSAPrivateKey)
RESOLVEFUNC(PEM_write_bio_DSAPrivateKey)
RESOLVEFUNC(PEM_write_bio_RSAPrivateKey)
#endif
RESOLVEFUNC(PEM_read_bio_DSA_PUBKEY)
RESOLVEFUNC(PEM_read_bio_RSA_PUBKEY)
RESOLVEFUNC(PEM_write_bio_DSA_PUBKEY)
RESOLVEFUNC(PEM_write_bio_RSA_PUBKEY)
RESOLVEFUNC(RAND_seed)
RESOLVEFUNC(RAND_status)
RESOLVEFUNC(RSA_free)
RESOLVEFUNC(sk_free)
RESOLVEFUNC(sk_num)
RESOLVEFUNC(sk_pop_free)
RESOLVEFUNC(sk_value)
RESOLVEFUNC(SSL_CIPHER_description)
RESOLVEFUNC(SSL_CTX_check_private_key)
RESOLVEFUNC(SSL_CTX_ctrl)
RESOLVEFUNC(SSL_CTX_free)
RESOLVEFUNC(SSL_CTX_new)
RESOLVEFUNC(SSL_CTX_set_cipher_list)
RESOLVEFUNC(SSL_CTX_set_default_verify_paths)
RESOLVEFUNC(SSL_CTX_set_verify)
RESOLVEFUNC(SSL_CTX_set_verify_depth)
RESOLVEFUNC(SSL_CTX_use_certificate)
RESOLVEFUNC(SSL_CTX_use_certificate_file)
RESOLVEFUNC(SSL_CTX_use_PrivateKey)
RESOLVEFUNC(SSL_CTX_use_RSAPrivateKey)
RESOLVEFUNC(SSL_CTX_use_PrivateKey_file)
RESOLVEFUNC(SSL_accept)
RESOLVEFUNC(SSL_clear)
RESOLVEFUNC(SSL_connect)
RESOLVEFUNC(SSL_free)
RESOLVEFUNC(SSL_get_ciphers)
RESOLVEFUNC(SSL_get_current_cipher)
RESOLVEFUNC(SSL_get_error)
RESOLVEFUNC(SSL_get_peer_cert_chain)
RESOLVEFUNC(SSL_get_peer_certificate)
RESOLVEFUNC(SSL_get_verify_result)
RESOLVEFUNC(SSL_library_init)
RESOLVEFUNC(SSL_load_error_strings)
RESOLVEFUNC(SSL_new)
#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
RESOLVEFUNC(SSL_ctrl)
#endif
RESOLVEFUNC(SSL_read)
RESOLVEFUNC(SSL_set_accept_state)
RESOLVEFUNC(SSL_set_bio)
RESOLVEFUNC(SSL_set_connect_state)
RESOLVEFUNC(SSL_shutdown)
RESOLVEFUNC(SSL_write)
#ifndef OPENSSL_NO_SSL2
RESOLVEFUNC(SSLv2_client_method)
#endif
RESOLVEFUNC(SSLv3_client_method)
RESOLVEFUNC(SSLv23_client_method)
RESOLVEFUNC(TLSv1_client_method)
#ifndef OPENSSL_NO_SSL2
RESOLVEFUNC(SSLv2_server_method)
#endif
RESOLVEFUNC(SSLv3_server_method)
RESOLVEFUNC(SSLv23_server_method)
RESOLVEFUNC(TLSv1_server_method)
RESOLVEFUNC(X509_NAME_entry_count)
RESOLVEFUNC(X509_NAME_get_entry)
RESOLVEFUNC(X509_NAME_ENTRY_get_data)
RESOLVEFUNC(X509_NAME_ENTRY_get_object)
RESOLVEFUNC(X509_PUBKEY_get)
RESOLVEFUNC(X509_STORE_free)
RESOLVEFUNC(X509_STORE_new)
RESOLVEFUNC(X509_STORE_add_cert)
RESOLVEFUNC(X509_STORE_CTX_free)
RESOLVEFUNC(X509_STORE_CTX_init)
RESOLVEFUNC(X509_STORE_CTX_new)
RESOLVEFUNC(X509_STORE_CTX_set_purpose)
RESOLVEFUNC(X509_STORE_CTX_get_error)
RESOLVEFUNC(X509_STORE_CTX_get_error_depth)
RESOLVEFUNC(X509_STORE_CTX_get_current_cert)
RESOLVEFUNC(X509_STORE_CTX_get_chain)
RESOLVEFUNC(X509_cmp)
#ifndef SSLEAY_MACROS
RESOLVEFUNC(X509_dup)
#endif
RESOLVEFUNC(X509_EXTENSION_get_object)
RESOLVEFUNC(X509_free)
RESOLVEFUNC(X509_get_ext)
RESOLVEFUNC(X509_get_ext_count)
RESOLVEFUNC(X509_get_ext_d2i)
RESOLVEFUNC(X509_get_issuer_name)
RESOLVEFUNC(X509_get_subject_name)
RESOLVEFUNC(X509_verify_cert)
RESOLVEFUNC(d2i_X509)
RESOLVEFUNC(i2d_X509)
#ifdef SSLEAY_MACROS
RESOLVEFUNC(i2d_DSAPrivateKey)
RESOLVEFUNC(i2d_RSAPrivateKey)
RESOLVEFUNC(d2i_DSAPrivateKey)
RESOLVEFUNC(d2i_RSAPrivateKey)
#endif
RESOLVEFUNC(OPENSSL_add_all_algorithms_noconf)
RESOLVEFUNC(OPENSSL_add_all_algorithms_conf)
RESOLVEFUNC(SSL_CTX_load_verify_locations)
RESOLVEFUNC(SSLeay)
symbolsResolved = true;
delete libs.first;
delete libs.second;
return true;
}
#endif // QT_NO_LIBRARY
#else // !defined QT_LINKED_OPENSSL
bool q_resolveOpenSslSymbols()
{
@ -729,7 +295,6 @@ bool q_resolveOpenSslSymbols()
#endif
return true;
}
#endif // !defined QT_LINKED_OPENSSL
//==============================================================================
// contributed by Jay Case of Sarvega, Inc.; http://sarvega.com/

View file

@ -60,107 +60,6 @@ QT_BEGIN_NAMESPACE
#define DUMMYARG
#if !defined QT_LINKED_OPENSSL
// **************** Shared declarations ******************
// ret func(arg)
# 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) { \
if (!_q_##func) { \
qWarning("QSslSocket: cannot call unresolved function "#func); \
err; \
} \
funcret _q_##func(a); \
}
// ret func(arg1, arg2)
# 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) { \
if (!_q_##func) { \
qWarning("QSslSocket: cannot call unresolved function "#func);\
err; \
} \
funcret _q_##func(a, b); \
}
// ret func(arg1, arg2, arg3)
# 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) { \
if (!_q_##func) { \
qWarning("QSslSocket: cannot call unresolved function "#func); \
err; \
} \
funcret _q_##func(a, b, c); \
}
// ret func(arg1, arg2, arg3, arg4)
# 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) { \
if (!_q_##func) { \
qWarning("QSslSocket: cannot call unresolved function "#func); \
err; \
} \
funcret _q_##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) \
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) { \
if (!_q_##func) { \
qWarning("QSslSocket: cannot call unresolved function "#func); \
err; \
} \
funcret _q_##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) \
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) { \
if (!_q_##func) { \
qWarning("QSslSocket: cannot call unresolved function "#func); \
err; \
} \
funcret _q_##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) \
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) { \
if (!_q_##func) { \
qWarning("QSslSocket: cannot call unresolved function "#func); \
err; \
} \
funcret _q_##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) \
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) { \
if (_q_##func) { \
qWarning("QSslSocket: cannot call unresolved function "#func); \
err; \
} \
funcret _q_##func(a, b, c, d, e, f, g, h, i); \
}
// **************** Shared declarations ******************
#else // !defined QT_LINKED_OPENSSL
// **************** Static declarations ******************
@ -198,7 +97,6 @@ QT_BEGIN_NAMESPACE
// **************** Static declarations ******************
#endif // !defined QT_LINKED_OPENSSL
bool q_resolveOpenSslSymbols();
long q_ASN1_INTEGER_get(ASN1_INTEGER *a);