解决Qt升级后OpenSSL不能用问题

问题由来

最近重装了系统,想着顺便把Qt也升级起来吧,于是下载安装了LTS长期支持版本的Qt5.12.4。结果问题来了,之前跑的很好的arcGIS for Qt运行不了了,一直提示错误:

qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed

搜索结果

度娘永远是不行的,直接爬梯在谷歌上找到了答案,而且是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.dlllibssl-1_1.dll.

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

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)

解决问题

找到问题就好办了,解决吧。

  1. 找到Qt里的OpenSSL版本号
    代码里直接输入
 qDebug()<

运行之后输出

OpenSSL 1.1.1b  26 Feb 2019

  1. 下载安装OpenSSL1.1.1的二进制文件
    自己编译太麻烦,还是直接下载现成吧。传送门,注意根据自己需要的是32位还是64位选择对应的包。我下载的是Win64 OpenSSL v1.1.1c Light
    安装好之后将libcrypto-1_1-x64.dlllibssl-1_1-x64.dll两个文件拷贝到C:\Qt\Qt5.12.4\5.12.4\msvc2017_64\bin文件夹下即可
  2. 问题解决

你可能感兴趣的:(qt)