如何在Windows上安装QT的OpenSSL 1.1.0



我的目标是使用 QNetworkAccessManagerQNetworkRequest通过ssl连接从网页上获取源代码(或图像(。

OpenSSL 1.1.0不适用于QT 5.8!在编辑2中查找安装解决方案!

首先尝试:获取ssleay32.lib和libeay32.lib,然后将它们复制到调试和发布文件夹中。不工作。

第二次尝试:(由于胡说八道而删除(但它不再起作用。

代码(适用于普通HTTP(:

QUrl url = QUrl(name);
data.clear();
QNetworkRequest *request = new QNetworkRequest(url);
request->setRawHeader("User-Agent", userAgent);
QSslConfiguration sslConfiguration(QSslConfiguration::defaultConfiguration());
request->setSslConfiguration(sslConfiguration);
reply = webCtrl->get(*request);
connect(webCtrl, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
connect(reply, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
connect(reply, SIGNAL(finished()), this, SLOT(onReplyFinished()));

错误消息:

qt.network.ssl: QSslSocket: cannot call unresolved function d2i_DHparams
qt.network.ssl: QSslSocket: cannot call unresolved function DH_free
qt.network.ssl: QSslSocket: cannot call unresolved function d2i_DHparams
qt.network.ssl: QSslSocket: cannot call unresolved function DH_free
qt.network.ssl: QSslSocket: cannot call unresolved function d2i_DHparams
qt.network.ssl: QSslSocket: cannot call unresolved function DH_free
qt.network.ssl: QSslSocket: cannot call unresolved function SSLv23_client_method
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_CTX_new
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_library_init
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error
qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error
Error creating SSL context ()

编辑1:我发现这个Artikel和OpenSSL 1.1.0将使用QT 5.10,但在QT 5.8中不使用我使用的内容。在此Artikel中,我找到了QSslSocket::sslLibraryBuildVersionString()命令,并且需要OpenSSL版本:OpenSSL 1.0.2h 3 May 2016

我将稍后再查看其他OpenSSL版本,并在此帖子中编辑是否有效。

编辑2:下载OpenSSL 1.0.2h 3 May 2016并安装7ZIP和PERL。提取OpenSL文件夹并关注INSTALL.W64。转到bin文件夹,然后将libeay32-xxx.dllssleay32-xxx.dll复制到应用程序文件夹,然后将文件重命名为libeay32.dllssleay32.dll。谢谢 @[Max Go]。

现在SSL连接最终工作,但是关闭应用程序时会收到一条错误消息,并且在运行时使用了Web连接。

onlinetest.exe中的0x0000000000777772D1CB(ntdll.dll(的例外: 0xc0000005:访问违规读取位置0x00000000000074。

VS2015调试窗口" mem.c"行443:

  1. free_debug_func 0x0000000000000000 void(*)(void *, int)
  2. free_func 0x000007fee778b1ba {libeay32.dll!free} void(*)(void *)
  3. str 0x0000000002500cf0 void *

编辑3:我忘了编译-d debug .dll。只需将编译器模式更改为调试,生成debug .dll,如果不需要-D,则将其重命名,然后将调试.dll的.dll复制到DEBUG文件夹中,并将normal .dll和normal .dll中的.dll复制到发行文件夹中。

这是我用来从Visual Studio提示自动构建OpenSSL的脚本。它将构建一个32或64位库,具体取决于启用了哪个编译器。

先决条件(必须在路径中(:

  • 活动perl
  • 7zip
  • nasm
  • Visual Studio 2015或2017(我什么都没测试(
  • jom(可选(
:: Configurable Options
:: If you have jom available, set it to jom - it speeds up the build.
@set JOM=nmake
:: Choose a static or dynamic build
@set LIBTYPE=dynamic
:: OpenSSL version in the 1.0.2 series
@set SRC=openssl-1.0.2k
@if "%VSCMD_ARG_TGT_ARCH%"=="x86" (
    @set BITS=32
    @set DST=OpenSSL-Win32
    @set CONFIG=VC-WIN32
    @set SETUP=msdo_nasm
) else if "%VSCMD_ARG_TGT_ARCH%"=="x64" (
    @set BITS=64
    @set DST=OpenSSL-Win64
    @set CONFIG=VC-WIN64A
    @set SETUP=msdo_win64a
) else goto no_vscmd
@if "%LIBTYPE%"=="static" (
    @set LIBTYPE=nt
) else if "%LIBTYPE%"=="dynamic" (
    @set LIBTYPE=ntdll
) else goto no_libtype
@echo Building %SRC% for %BITS% bits.
@echo - Downloading
@perl ^
    -e "use LWP::Simple;" ^
    -e "mirror('https://www.openssl.org/source/%SRC%.tar.gz', '%SRC%.tar.gz');"
@echo - Decompressing
@if not exist %SRC%.tar.gz goto no_archive
@rmdir /S /Q %SRC% %DST% 2>NUL
@7z x -bsp2 -y %SRC%.tar.gz >NUL && ^
7z x -bsp2 -y %SRC%.tar     >NUL && ^
del %SRC%.tar
@if errorlevel 1 goto unpack_failed
@if not exist %SRC% goto no_source
@echo - Building
@pushd %SRC%
@perl Configure %CONFIG% --prefix=%~dp0..%DST% && ^
call %SETUP% && ^
nmake -f ms%LIBTYPE%.mak init && ^
%JOM% -f ms%LIBTYPE%.mak "CC=cl /FS" && ^
%JOM% -f ms%LIBTYPE%.mak test && ^
nmake -f ms%LIBTYPE%.mak install || goto build_failed
@popd
@rmdir /S /Q %SRC%
@echo Build has succeeded.
@goto :eof
:no_libtype
@echo Error: LIBTYPE must be either "static" or "dynamic">&2
@exit /b 1    
:no_archive
@echo Error: can't find %SRC%.tar.gz - the download has failed :(>&2
@exit /b 1
:unpack_failed
@echo Error: unpacking has failed.>&2
@exit /b %errorlevel%
:no_source
@echo Error: can't find %SRC%>&2
@exit /b 1
:build_failed
@echo The build had failed.>&2
@popd
@exit /b 2
:no_vscmd
@echo Use vcvarsall x86 or vcvarsall x64 to set up the Visual Studio>&2
@echo build environment first.>&2
@exit /b 100

相关内容

  • 没有找到相关文章

最新更新