当BIO是内存BIO而不是套接字BIO时,BIO_read/BIO_write和SSL_read/SSL_write有什么区别? [英] what is the difference between BIO_read/BIO_write and SSL_read/SSL_write when the BIOs are memory BIOs and not socket BIOs?
问题描述
当BIO是内存BIO而不是套接字BIO时,我对BIO例程BIO_read()
/BIO_write()
和SSL_read()
/SSL_write()
之间的区别感到困惑.
I am confused about the difference between the BIO routines BIO_read()
/BIO_write()
and the SSL_read()
/SSL_write()
when the BIOs are memory BIOs and not socket BIOs.
我正在尝试对ICE堆栈使用libnice
并对DTLS堆栈使用OpenSSL来对WebRTC服务器进行编码. ICE堆栈具有到客户端的套接字连接,因此我无法在OpenSSL中使用基于套接字的BIO.相反,我正在使用内存BIO.
I am trying to code a WebRTC server using libnice
for the ICE stack and OpenSSL for the DTLS stack. The ICE stack has the socket connection to the client so I cannot use the socket-based BIOs in OpenSSL. Instead, I am using the memory BIOs.
因此,我正在使用的高级过程是,当我从ICE套接字上的客户端收到DTLS消息时,我使用BIO_write()
将该消息写入DTLS堆栈.然后,当DTLS堆栈中有一条消息要发送到客户端时,我使用BIO_read()
收到该消息,然后使用ICE套接字将其发送到客户端.
So the high level procedure I am using is that, when I receive the DTLS messages from the client on the ICE socket, I write that message to the DTLS stack using BIO_write()
. Then when the DTLS stack has a message to send to the client I get that message using the BIO_read()
and send it to the client using the ICE socket.
我已经看到了一些本质上执行此过程的源代码示例,但它们还在BIO_write()
调用之后也调用了SSL_read()
例程.这对我来说毫无意义.在本质上已经使用BIO_write()
调用将客户端消息写入DTLS堆栈之后,为什么必须调用SSL_read()
?如果在BIO_write()
之后没有调用SSL_read()
,则我的代码将不起作用.但是,当我在BIO_write()
之后调用SSL_read()
时,确实确实是在与浏览器客户端交换握手消息.
I have seen some examples of source code that does essentially this procedure, but they also call the SSL_read()
routine after the BIO_write()
call. This makes no sense to me. Why is the call to SSL_read()
necessary after I essentially have written the client message into the DTLS stack using the BIO_write()
call? If I do not call SSL_read()
after the BIO_write()
my code does not work. But when I call SSL_read()
after the BIO_write()
, this is indeed exchanging the handshake messages with the browser client.
问题:使用内存BIO,BIO_read()
和SSL_read()
有什么区别?
Question: Using memory BIOs, what is the difference between BIO_read()
and SSL_read()
?
问题:使用内存BIO,BIO_write()
和SSL_write()
有什么区别?
Question: Using memory BIOs, what is the difference between BIO_write()
and SSL_write()
?
问题:默认的内存BIO是阻塞还是非阻塞?我假设它是非阻塞的,因为它是基于内存的BIO而不是基于套接字的BIO.
Question: Is the default memory BIO blocking or non-blocking? I am assuming it is non-blocking since it is a memory-based BIO and not a socket-base BIO.
谢谢,
-安德烈斯(Andres)
Thanks,
-Andres
推荐答案
我偶然发现了同样的问题,并且了解了整个过程.我可以为您提供一些有用的链接和引用.
I stumbled upon the same problem with understanding how the whole thing works. I can provide you with some useful links and cites.
" SSL层设置为在缓冲区模式下工作.因此,执行SSL_write意味着我们将未加密的字节发送到SSL库,以便它可以对这些字节进行加密并将生成的加密字节放入缓冲区中.然后,我们使用BIO_read从缓冲区进行读取.反之亦然.在这种情况下,我们实际上先进行BIO_write,然后进行SSL_read."
来源: https://groups.google.com/forum/#!topic/grpc-io/8Ulf_G5kpyA
OpenSSL数据处理-通过下面的链接检查此部分.它可能会给您一些有用的信息. https://famellee.wordpress.com/2013/02/20/use-openssl-with-io-completion-port-and-certificate-signing/
OpenSSL data handling - check this part from link below. It might give you some useful information. https://famellee.wordpress.com/2013/02/20/use-openssl-with-io-completion-port-and-certificate-signing/
BIO -从下面的链接中检查此部分.它可能会给您一些有用的信息. http://www.roxlu.com/2014/042/using -openssl-with-memory-bios
BIOs - check this part from link below. It might give you some useful information. http://www.roxlu.com/2014/042/using-openssl-with-memory-bios
这篇关于当BIO是内存BIO而不是套接字BIO时,BIO_read/BIO_write和SSL_read/SSL_write有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!