Qt SSL 支持缺失

发布于 2024-09-15 08:10:42 字数 133 浏览 2 评论 0原文

我刚刚下载了 Qt(LGPL - Qt SDK for Windows),当我运行一些演示时,他们抱怨 Qt 没有 SSL。
如何获取启用了 SSL 的 Qt SDK?我真的需要从源代码编译它以获得 SSL 支持吗?为什么我下载的版本中缺少它?

I've just downloaded Qt (LGPL - Qt SDK for Windows) and when i run some of the demos they complain about Qt not having SSL.
How can i get the Qt SDK with SSL enabled? Do i really need to compile it from source to get SSL support? Why is it missing in the version i've downloaded?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

花辞树 2024-09-22 08:10:42

@user261882 答案仅部分正确。他正确地说 Qt 不支持 SSL,您确实需要下载 OpenSSL 库

然而,之后的链接过程要简单得多,您不需要在下载 SSL 库后重建 Qt 或摆弄 Microsoft Visual 的东西。 Qt 让这一切变得简单。

下载 SSL 库后,您需要做的就是确保 Qt 可以找到这些 openSSL 库所在的位置。如果在下载过程中选择将 openSSL DLL 复制到 Windows 系统目录的选项, Qt 将自动在该目录中查找 openSSL 二进制文件,因为 Windows 始终搜索 Windows 系统目录。

如果您不想在 Windows 系统目录中安装 openSSL 库,那也没关系,您只需告诉 Qt openSSL DLL 的位置即可。您可以通过多种方式执行此操作...一种可能的解决方案是将 openSSL DLL 的位置添加到系统路径中。另一个简单的解决方案是将 openSSL DLL 复制到包含可执行文件的目录中。该目录也保证会被搜索到。

您可以稍后运行一个简单的检查,看看这是否有效,即调用静态函数QSslSocket:: supportSsl(),如果此函数返回 true,则 Qt 已找到您下载的 openSSL 二进制文件。(当然,请确保您在 中添加 Qt += network >.pro 文件,然后运行此测试)

使用 Qt Creator 2.5.2 和 Win32 OpenSSL 库 v1.0.1c 使用 Qt 4.8.3 二进制文件进行测试

希望这可以为每个人节省一些时间。通过这种方式,您不需要去搜索 Visual Studio 文件,而且要简单得多。

@user261882 answer is only partially correct. He is correct in saying that Qt does not come with SSL support and that you do need to download the OpenSSL libraries.

However, the linking process after is much more simple, you do not need to rebuild Qt after downloading the SSL libraries or mess around with Microsoft Visual stuff. Qt makes it easy for you.

All that you need to do after downloading the SSL libraries is ensure that Qt can find where these openSSL libraries are located. If during your download you select the option to copy the openSSL DLL's to the Windows system directory, Qt will automatically find the openSSL binaries in that directory since the Windows system directory is always searched by Windows.

If you do not wish to install the openSSL libraries in your Windows system directory, that is fine, you just need to tell Qt where the openSSL DLL's are located. You can do this in a number of ways... one possible solution is setting adding the openSSL DLL's location to the system PATH. Another simple solution is to copy the openSSL DLL's into the directory which contains your executable. This directory is guaranteed to be searched as well.

A simple check that you can run afterwards to see if this worked is call the static function QSslSocket::supportsSsl(), if this function returns true, Qt has found the openSSL binaries that you downloaded. (Of course ensure that you add Qt += network in your .pro file before running this test)

Tested with Qt 4.8.3 binaries, using Qt Creator 2.5.2, and Win32 OpenSSL libraries v1.0.1c

Hope this saves everyone some time. Doing it this way you don't need to go and search the Visual Studio files and it is much simpler.

关于从前 2024-09-22 08:10:42

要为 Qt 启用 SSL,您首先必须下载 OpenSSL 包。为此,我建议下载此处提供的 OpenSSL 二进制文件。 安装二进制文件并阅读它们附带的帮助。

这部分用于在 Microsoft Visual C++ 下安装 OpenSSL 二进制文件(下面的文本摘自二进制文件的帮助)

OpenSSL 旨在轻松构建
在 Microsoft Visual C++ 下。然而,
你去获得的要求
25MB Win98 DDK 并拥有最新的
已安装服务包(SP5为120MB)
可能会成为某些人的障碍
人们(特别是那些有
调制解调器)。

那么,Win32的安装
OpenSSL 二进制文件相当简单
过程(类似于Borland C++
构建器进程)。

首先要做的事情(假设
默认安装“C:\OpenSSL”)
是去'C:\OpenSSL\lib\VC'并且
将所有文件复制到您的视觉
C++“lib”目录。这个目录是
有时位于某个
神秘位置,例如“C:\Program”
文件\微软视觉
Studio\VC98\lib' 或 'C:\Program
文件\Microsoft Visual C++\lib'。

接下来,复制所有内容
'C:\OpenSSL\include' 目录到您的
Visual C++“包含”目录。

就是这样!你已经准备好开始写作了
支持 OpenSSL 的代码!

设置正确的参数后,您现在可以配置 Qt 以启用 SSL 支持。
运行configure.exe -debug-and-release -webkit -openssl -IC:\openssl\Include -LC:\openssl\Lib,然后运行nmake。您已启用 SSL 支持。不要忘记将 Qt += network 放入您的 .pro 文件中。

这对我和我的同事有用,也应该对你有用:)。

To enable SSL for Qt, you first must download the OpenSSL package. For that I suggest to download the binaries for OpenSSL that are availiable here. Install the binaries and read the help that comes with them.

This part is for installing OpenSSL binaries under Microsoft Visual C++(the text under is taken from the help of the binaries)

OpenSSL is designed to build easily
under Microsoft Visual C++. However,
the requirement that you go and obtain
the 25MB Win98 DDK and have the latest
service pack (SP5 is 120MB) installed
can prove to be a hinderance to some
people (particularly those with
modems).

So, the installation of the Win32
OpenSSL binaries is a fairly simple
process (similar to the Borland C++
Builder process).

The first thing to do (assuming a
default installation of 'C:\OpenSSL')
is to go to 'C:\OpenSSL\lib\VC' and
copy all of the files to your Visual
C++ 'lib' directory. This directory is
sometimes located in a somewhat
cryptic location such as 'C:\Program
Files\Microsoft Visual
Studio\VC98\lib' or 'C:\Program
Files\Microsoft Visual C++\lib'.

Next, copy everything in the
'C:\OpenSSL\include' directory to your
Visual C++ 'include' directory.

That's it! You are ready to go write
OpenSSL-capable code!

After setting the right parameters, you are now ready to configure Qt to enable SSL support.
Run configure.exe -debug-and-release -webkit -openssl -I C:\openssl\Include -L C:\openssl\Lib, and then nmake. You have enabled SSL support. Don't forget to put Qt += network in your .pro file.

That had worked for me and for my colleagues, should work for you too:).

娇纵 2024-09-22 08:10:42

来自 Qt 文档

从源代码构建 Qt 时,配置系统会检查 OpenSSL 源代码或开发人员包提供的 openssl/opensslv.h 标头是否存在。由于世界某些地区的进出口限制,我们无法提供带有 Qt 软件包的 OpenSSL 工具包。希望在部署的应用程序中使用 SSL 通信的开发人员应确保其用户安装了适当的库,或者应咨询具有适当资格的法律专业人士,以确保使用 OpenSSL 项目代码的应用程序正确无误拥有世界相关地区的进出口认证。

如果您已经安装了 OpenSSL,请尝试

在您的 .pro 文件中提供 Qt += network ..

希望它有帮助..

From Qt Documentation,

When building Qt from source, the configuration system checks for the presence of the openssl/opensslv.h header provided by source or developer packages of OpenSSL. Due to import and export restrictions in some parts of the world, we are unable to supply the OpenSSL Toolkit with Qt packages. Developers wishing to use SSL communication in their deployed applications should either ensure that their users have the appropriate libraries installed, or they should consult a suitably qualified legal professional to ensure that applications using code from the OpenSSL project are correctly certified for import and export in relevant regions of the world.

If you have already OpenSSL installed, try giving

Qt += network in your .pro file..

Hope it helps..

夜夜流光相皎洁 2024-09-22 08:10:42

QT 5.15:

  1. 确保您已使用 Qt Maintenance Tool 安装了 OpenSSL Toolkit
  2. 转到 C:\Qt\Tools\OpenSSL\Win_x64\bin 并搜索“libcrypto-1_1-x64.dll”和“libssl-1_1-x64.dll
  3. ”将它们放入编译器文件夹 (C:\Qt\5.15.2\msvc2019_64\bin)

注意:如果编译 x86 变体,则必须从 Win_x86 文件夹复制 DLL,

我在这里找到了这个答案:https://www.programmersought.com/article/71774817627/

QT 5.15:

  1. Make sure you have installed OpenSSL Toolkit using Qt Maintenance Tool
  2. Go to C:\Qt\Tools\OpenSSL\Win_x64\bin and search for "libcrypto-1_1-x64.dll" and "libssl-1_1-x64.dll
  3. Copy them into the compiler folder (C:\Qt\5.15.2\msvc2019_64\bin)

NOTE: if you compile x86 variant you have to copy DLLs from the Win_x86 folder.

I found this answer here: https://www.programmersought.com/article/71774817627/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文