Qt5.9.12.7 Https访问TLS initialization failed错误

1.错误产生原因:

对于高于(且包含)Qt5.12.4的QT版本,在https请求时,会使用OpenSSL加密.
在Qt官网给出的release note里写的


 We wanted to update now as the earlier version of OpenSSL runs out of support 
 at the end of the year . Unfortunately OpenSSL 1.1 is binary incompatible with 1.0,
 so users need to switch to the new one and repackage their applications.
 One important functionality enabled by OpenSSL 1.1 is TLS 1.3 bringing significant
 cryptography and speed improvements.

大意就是 Qt自带的老版本OpenSSL1.0.x在今年(2019)就要结束LTS支持了,那么从本版本开始(5.12.4)Qt将启用1.1.x,新版本带来的TLS1.3很牛逼blabla,
但我就搞不懂了,你升级就升级,把dll的名字改了干嘛啊?以前经典的libeay32.dllssleay32.dll变成了libcrypto-1_1.dll** 和libssl-1_1.dll.

去OpenSSL官网看了下,也是这么说的

 he latest stable version is the 1.1.1 series. This is also our Long Term Support 
 (LTS) version,  supported until 11th September 2023. Our previous LTS version 
 (1.0.2 series) will continue to be supported until 31st December 2019 
 (security fixes only during the last year of support)
 The latest stable version is the 1.1.1 series.  This is also our Long Term Support
 (LTS) version, supported until 11th September 2023.  Our previous LTS version 
 (1.0.2 series) will continue to be supported until 31st December 2019 
 (security fixes only during the last year of support)

2. 解决方法:

2.1.找到Qt里的OpenSSL版本号:

qDebug()<<QSslSocket::sslLibraryBuildVersionString();
//输出如下:OpenSSL 1.1.1d  26 Feb 2019

2.2下载安装OpenSSL1.1.1的二进制文件

http://slproweb.com/products/Win32OpenSSL.html
注意根据自己需要的是32位还是64位选择对应的包。我下载的是Win32OpenSSL_Light-1_1_1d.exe
安装好之后将libcrypto-1_1.dlllibssl-1_1.dll两个文件拷贝到D:\Qt\Qt5.12.7\Tools\mingw730_32\bin文件夹下即可

你可能感兴趣的:(Qt)