默认的BIO_METHOD从OpenSSL 1.0.2迁移到1.1.1

时间:2019-04-24 12:02:37

标签: c openssl

我试图将我的应用程序代码从OpenSSL 1.0.2移植到1.1.1,但遇到了我似乎无法理解的更改。

在1.0.2中,我们通过调用替换了bread的默认bwriteBIO_s_socket方法:

orig_bread = BIO_s_socket()->bread;
orig_bwrite = BIO_s_socket()->bwrite;
BIO_s_socket()->bread = my_bread;
BIO_s_socket()->bwrite = my_bwrite;

但是,在OpenSSL 1.1.1中,据说BIO_s_socket()返回const BIO_METHOD*而不是BIO_METHOD*。如何更改此版本的默认行为?

编辑:(...如果再也不能做,如何为每个ssl连接设置面包和bwrite?)

1 个答案:

答案 0 :(得分:0)

I'm trying to port my application code from OpenSSL 1.0.2 to 1.1.0

Firstly I recommend you move to 1.1.1 not 1.1.0. 1.1.1 is a Long Term Support version (LTS) and will be supported until 2023. 1.1.0 support ends later this year.

You need to create a custom BIO_METHOD. In brief you create one using BIO_meth_new() and then set custom read and write functions using BIO_meth_set_read() and BIO_meth_set_write(). Depending on what your BIO_METHOD does you may need to call other set functions. They are all documented here:

https://www.openssl.org/docs/man1.1.1/man3/BIO_meth_new.html

内的字符串的所有实例