OpenSSL生物线程安全

发布于 2025-02-08 09:14:35 字数 212 浏览 0 评论 0原文

OpenSSL关于线程安全的常见问题解答说:

是的,但是有一些局限性;例如,SSL连接不能由多个线程同时使用。对于大多数OpenSSL对象都是如此。

它不允许我理解以下内容是否安全:

  1. 我会在Bio上拨打blocking ,我致电该简历。
  2. 如果在收到响应之前终止我的申请,

OpenSSL's FAQ about thread safety says the following:

Yes but with some limitations; for example, an SSL connection cannot be used concurrently by multiple threads. This is true for most OpenSSL objects.

It does not allow me to understand whether the following will be safe:

  1. I call a blocking read on a BIO
  2. If my application should be terminated before the response is received, I call close on that BIO

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

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

发布评论

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

评论(1

陌路终见情 2025-02-15 09:14:35

如果您使用2个不同线程使用相同的BIO对象调用2个功能,则OpenSSL不保证线程安全。但是,这不是您在做的事情。

您正在两个不同的线程之间共享 fd bio_read()在一个线程中调用fd的一个副本正在使用openssl库在一个线程中使用,并且您在不同的fd上调用collect()线。

Linux可以以这种方式共享FD,因此在您的情况下应该没有问题。我不能说窗户。

OpenSSL does not guarantee thread safety if you call 2 functions using the same BIO object at the same time from 2 different threads. However that is not what you are doing.

You are sharing an fd between two different threads. One copy of the fd is being used by the OpenSSL library in the BIO_read() call in one thread, and you are calling close() on the same fd in a different thread.

Sharing an fd in this way is allowed on Linux so there should be no problems in your case. I can't speak for Windows.

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