关于在 pthreads 中使用 OpenSSL 的教程 [英] Tutorial on Using OpenSSL with pthreads

查看:28
本文介绍了关于在 pthreads 中使用 OpenSSL 的教程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OpenSSL 文档声明它可以安全地用于多线程应用程序前提是至少设置了两个回调函数,locking_function 和 threadid_func....

OpenSSL documents state that it can safely be used in multi-threaded applications provided that at least two callback functions are set, locking_function and threadid_func....

我编写了使用 OpenSSL API 的程序.此外,我知道如何使用 pthreads.但是,OpenSSL 文档是以手册的形式编写的,我看不到在多线程应用中使用 OpenSSL 时必须执行的操作的分步指南.

I've written programs which use OpenSSL API. Moreover, I know how to use pthreads. However, the OpenSSL documents are written in the form of a manual, and I can't see a step-by-step guide on what I have to do when using OpenSSL in a multi-threaded app.

是否有关于在 pthreads 中使用 OpenSSL 的教程?(我在网上搜索,但没有出现满意的结果.)

Is there a tutorial on using OpenSSL with pthreads? (I searched the web, but no satisfactory result appeared.)

PS:我在 Debian Lenny &Ubuntu Lucid/Maverick.

PS: I'm working in Debian Lenny & Ubuntu Lucid/Maverick.

PS2:OpenSSL 包含一个示例,但它太复杂了,无法开始.

PS2: OpenSSL includes a sample, but it's far too complicated to start with.

推荐答案

本书第 10 章 Linux 网络编程权威指南 包括一个部分使用 OpenSSL 进行线程安全编程(第 255-259 页).本节详细介绍 OpenSSL 和 pthreads 库的工作原理.特别地,它告诉了如何在静态分配(其中线程数先验)和动态分配(其中线程创建和销毁动态)中设置回调函数em>).

Chapter 10 of the book The Definitive Guide to Linux Network Programming includes a section Thread-safe Programming with OpenSSL (on pages 255-259). This section details how OpenSSL and the pthreads library work. Specially, it tells how to setup the callback functions both in static allocation (where the number of threads are known a priori) and dynamic allocation (where threads are created and destroyed on the fly).

另一个很好的来源是 Network Security withOpenSSL,标题为多线程支持.它分别在 4.1.1 和 4.1.2 小节中提供了静态/动态分配机制.

Another good source is Section 4.1 of the book Network Security with OpenSSL, titled Multithread Support. It provides static/dynamic allocation mechanisms in subsections 4.1.1 and 4.1.2, respectively.

最后,有一本书 Unix-Netzwerkprogrammierung mit Threads, Socketsund SSL,这是迄今为止关于该主题的最全面的一个.不幸的是,这本德语书的英文翻译不可用.

Finally, there's the book Unix-Netzwerkprogrammierung mit Threads, Sockets und SSL, which is by far the most comprehensive one on the subject. Unfortunately, the English translation of this German book is not available.

上述参考文献现在被认为已过时,因为 OpenSSL 1.1.0 变更日志 解释:

The above references are now considered obsolete, as OpenSSL 1.1.0 changelog explains:

OpenSSL 现在使用新的线程 API.在多线程环境中使用 OpenSSL 不再需要设置锁定回调. 支持两种线程模型:pthreads 和 windows 线程.还可以在编译时为无线程"配置 OpenSSL.不应再使用旧的线程 API.这些功能已被替换为无操作".兼容性宏.

OpenSSL now uses a new threading API. It is no longer necessary to set locking callbacks to use OpenSSL in a multi-threaded environment. There are two supported threading models: pthreads and windows threads. It is also possible to configure OpenSSL at compile time for "no-threads". The old threading API should no longer be used. The functions have been replaced with "no-op" compatibility macros.

[亚历山德罗·盖迪尼、马特·卡斯韦尔]

[Alessandro Ghedini, Matt Caswell]

在 OpenSSL 博客文章 OpenSSL 和线程.

This is further elaborated in OpenSSL blog post OpenSSL and Threads.

另请参阅 OpenSSL GitHub 存储库上的此问题,该存储库自 2017 年起开放.

See also this issue on OpenSSL GitHub repository, which is open since 2017.

这篇关于关于在 pthreads 中使用 OpenSSL 的教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆