简体   繁体   English

强制系统QT库使用随应用程序一起提供的openssl库

[英]Force system QT libraries to use openssl libraries shipped with the application

My application = libssl.so ( 1.0.2f ) + libcrypto.so ( 1.0.2f ) + my_app_exe 我的应用程序= 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 在Debian 9上,QT版本是5.7 ,openssl是1.0.2l

my_app_exe returns 1.0.2l for QSslSocket::sslLibraryVersionString() , which means its using system openssl version. my_app_exeQSslSocket::sslLibraryVersionString()返回1.0.2l ,这意味着它使用系统openssl版本。

Can I force QT libraries to somehow use openssl shipped along with my application? 我可以强制QT库以某种方式使用我的应用程序随附的openssl吗?

I've tried setting library path using QCoreApplication::addLibraryPath(const QString &path) , but QT library still picks up system openssl version. 我已经尝试使用QCoreApplication::addLibraryPath(const QString &path)设置库路径,但是QT库仍然会选择系统openssl版本。

Constraints: 约束:

  • Can't recompile QT library thats present on the system 无法重新编译系统上存在的QT库
  • Can't ship QT library along with the application 无法随应用程序一起提供QT库
  • Can't change RPATH on system QT libraries 无法更改系统QT库上的RPATH

my_app_exe already uses RPATH which points to the current directory where shipped openssl resides. my_app_exe已经使用RPATH指向openssl所在的当前目录。

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. 在Debian 9上,如果我使用QLibrary调用预加载(将它们作为main()中的第一个加载),我就可以加载正确的SSL和加密库。 This is exactly what QT libraries are doing loadOpenSsl() 这正是QT库正在做的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 记住,我也在应用程序上设置了RPATH

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

crypto libraries are stored in ./my_app_exe/lib/lib{ssl,crypto}.so 加密库存储在./my_app_exe/lib/lib{ssl,crypto}.so

BTW, setting LD_LIBRARY_PATH didn't work for me. 顺便说一句,设置LD_LIBRARY_PATH对我来说不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM