3

My application = libssl.so (1.0.2f) + libcrypto.so (1.0.2f) + my_app_exe

On Debian 9, QT version is 5.7 and openssl is 1.0.2l

my_app_exe returns 1.0.2l for QSslSocket::sslLibraryVersionString(), which means its using system openssl version.

Can I force QT libraries to somehow use openssl shipped along with my application?

I've tried setting library path using QCoreApplication::addLibraryPath(const QString &path), but QT library still picks up system openssl version.

Constraints:

  • Can't recompile QT library thats present on the system
  • Can't ship QT library along with the application
  • Can't change RPATH on system QT libraries

my_app_exe already uses RPATH which points to the current directory where shipped openssl resides.

JamesWebbTelescopeAlien
  • 3,547
  • 2
  • 30
  • 51

1 Answers1

4

On Debian 9 I was able to get the correct SSL and Crypto libraries to load if I preload (load them as the first thing in the main()) using QLibrary calls. This is exactly what QT libraries are doing loadOpenSsl()

    int main()
    {
        QLibrary libcrypto, libssl;
        libcrypto.setFileNameAndVersion(QLatin1String("crypto"), QLatin1String(SHLIB_VERSION_NUMBER));    
        libssl.setFileNameAndVersion(QLatin1String("ssl"), QLatin1String(SHLIB_VERSION_NUMBER));

        ...<snipped>...
        return 0;
     }

Remember, I also have RPATH set on the application

$ objdump -x my_app_exe | grep -i RPATH
  RPATH                $ORIGIN/lib

crypto libraries are stored in ./my_app_exe/lib/lib{ssl,crypto}.so

BTW, setting LD_LIBRARY_PATH didn't work for me.

JamesWebbTelescopeAlien
  • 3,547
  • 2
  • 30
  • 51