什么是 OpenSSL BIO 对以及如何使用 OpenSSL BIO 对?

发布于 2024-07-11 21:46:02 字数 66 浏览 5 评论 0 原文

OpenSSL 中的 BIO 对到底是什么?它的用途是什么? 我已经检查过 OpenSSL 文档,但任何细节都很少。

What exactly is a BIO pair in OpenSSL, and how is it intended to be used? I've already checked the OpenSSL docs, but any details are few and far between.

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

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

发布评论

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

评论(3

清泪尽 2024-07-18 21:46:02

OpenSSL 中的 BIO 类似于文件句柄。 您可以使用一对它们来安全地相互通信,就像使用两个套接字一样。 我发现的最好的解释是 此处

几个月前,当我不得不写的时候,我也从 Herong Yang 的网站中得到了很多使用使用 OpenSSL 的应用程序。 关于使用 OpenSSL 和 keytool 创建和签署证书的部分在测试我的应用程序时提供了很大的帮助。

A BIO in OpenSSL is similar to a File handle. You use a pair of them to communicate with each other securely like you would with two sockets. The best explanation I've found is here.

I also got a lot of use out of Herong Yang's site a few months ago when I had to write an application using OpenSSL. The sections on creating and signing certificates using OpenSSL and keytool were a big help when it came to testing my application.

開玄 2024-07-18 21:46:02

BIO 对是绑定在一起的两个源/接收器 BIO。 写入一个的任何内容都可以从另一个读取。 如果您已经有两个 BIOS,则可以使用 BIO_make_bio_pair 将它们连接在一起。 或者您可以使用 BIO_new_bio_pair 创建一个新的 BIO 对。

《Network Security with OpenSSL》一书中提到的一个用途(请参阅第 111 页)是该对可以绑定到 SSL 引擎。 SSL 引擎将读取写入 BIO 对的任何内容。 写入 BIO 对的任何内容都可以读取。 OpenSSL 有一个示例(请参阅 ssl/ssltest.c)

A BIO pair are two source/sink BIOs that are bound together. Anything that is written to one can be read from the other. If you have two BIOS already, you can join them together using BIO_make_bio_pair. Or you can create a new BIO pair with BIO_new_bio_pair.

One use mentioned in the Network Security with OpenSSL book (see page 111) is that the pair can be bound to a SSL engine. Anything written to the BIO pair will be read by the SSL engine. Anything written to the BIO pair can be read from. OpenSSL has a sample of this (see ssl/ssltest.c)

浅忆 2024-07-18 21:46:02

我已经写过有关 OpenSSL BIO 对的文章,作为有关 OpenSSL BIO 的一般答案的一部分:

“生物”BIO (BIO_s_bio)。 它是一个类似管道的BIO。 可以创建一对这样的 BIO。 写入该对中的一个 BIO 的数据将被放置到该对中的第二个 BIO 中以供读取。 反之亦然。 它与内存BIO类似,但内存BIO将数据放置到自身,而管道BIO将数据放置到与其配对的BIO。

还有此处

但除此之外,还有一个名为 BIO_s_bio 的 BIO,它具有类似管道的功能。 可以创建一对这样的 BIO。 写入 BIO_s_bio 对象对中第一个 BIO 的任何数据都将从该对中的第二个 BIO 读取。 反之亦然:向第二个 BIO 写入数据将导致从第一个 BIO 读取该数据。 因此可以使用BIO_s_bio代替BIO_s_mem。 将 BIO_s_bio 对象的单个实例传递给 SSL_set_bio 函数就足够了。 应用程序接收数据并将其写入 BIO_s_bio 对中的 BIO。 然后 OpenSSL 将从该对中的 BIO 中获取此数据。 OpenSSL 将数据写入该对中的 BIO,应用程序依次从其 BIO 中获取该数据。

I've written about OpenSSL BIO pairs as a part of a general answer about OpenSSL BIOs:

A "bio" BIO (BIO_s_bio). It is a pipe-like BIO. A pair of such BIOs can be created. Data written to one BIO in the pair will be placed for reading to the second BIO in the pair. And vice versa. It is similar to memory BIO, but memory BIO places data to itself and pipe BIO places data to the BIO which it is paired with.

And also here:

But in addition there is a BIO called BIO_s_bio which has a pipe-like functionality. A pair of such BIOs can be created. Any data written to the first BIO in the pair of BIO_s_bio objects will be read from the second BIO in the pair. And vice versa: writing data to the second BIO will result in reading this data from the first BIO. So BIO_s_bio can be used instead of BIO_s_mem. Passing a single instance of BIO_s_bio object to the SSL_set_bio function would be enough. Application receives data and writes it to its BIO in the BIO_s_bio pair. OpenSSL will then get this data from its BIO in the pair. OpenSSL writes data to its BIO in the pair, and the application gets this data from its BIO in turn.

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