文章声明:下述所有文字均手写,并真实尝试,无任何AI代写,老子玩的就是真实,如果有用,点个赞给小子呗
适用场景:本文适用于使用qt soket相关网络模块需要向https发送请求的问题
问题描述:
2025-02-24 19:19:14: 0x0000a528 Debug: SSL not supported!
或者访问https失败显示tls相关问题的
问题原因:
由于PC没有安装openssl等相关认证的库,导致qt ssl初始化失败
解决方案
步骤三:
先在你的代码块中加上下述代码,debug打印你qt版本对应的openssl
if (QSslSocket::supportsSsl()) {
qDebug() << "SSL not supported!";
qDebug() << "SSL version:" << QSslSocket::sslLibraryVersionString();
qDebug() << "SSL library:" << QSslSocket::sslLibraryBuildVersionString();
} else {
qDebug() << "SSL supported!";
}
如果不支持会有下面打印
2025-02-24 19:19:14: 0x0000a528 Debug: SSL not supported! (244, ..\..\src\sureprint\sureprint.cpp, void __thiscall SurePrint::downloadPdf(const class QUrl))
2025-02-24 19:19:14: 0x0000a528 Debug: SSL version: "OpenSSL 1.1.0h 27 Mar 2018" (245, ..\..\src\sureprint\sureprint.cpp, void __thiscall SurePrint::downloadPdf(const class QUrl))
2025-02-24 19:19:14: 0x0000a528 Debug: SSL library: "" (246, ..\..\src\sureprint\sureprint.cpp, void __thiscall SurePrint::downloadPdf(const class QUrl))
凡是显示1.x.x都可以使用openssl相关的包,大版本不变即可
步骤二:
安装openssl 参考:Ahua-Tan/openssl1.1
32位包网址:https://github.com/Ahua-Tan/openssl1.1/releases/download/openssl-1.1.0_h/Win32OpenSSL-1_1_0h.exe
64位包网址: https://github.com/Ahua-Tan/openssl1.1/releases/download/openssl-1.1.0_h/Win64OpenSSL-1_1_0h.exe
在安装界面最后把bin安装在软件安装目录中
步骤三:将下面两个dll放到对应编译器的bin文件夹下如下图
64位的库就放64位对应的bin里面