本文介绍了阻塞到非阻塞模式更改的OpenSSL的BIO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多线程应用程序,使大量使用的OpenSSL在C.它设计的想法,所有的SSL连接,预计阻拦。具体来说,阻断BIOS。他们都分配了一个进入端口是这样的:

  SSL = SSL_new(CTX);
SSL_set_mode(SSL,SSL_MODE_AUTO_RETRY);
袜子= BIO_new_socket(插座,BIO_CLOSE);
SSL_set_bio(SSL,袜子,袜子);

事实证明,虽然,也有codeBase类的,其中使用非阻塞的BIOS会是最好的选择了几个小零件。这将在非阻塞的BIOS中受益的小零件不知道哪个SSL连接将属于他们的方式。因此,他们总是收到阻塞BIOS。

的问题是,能阻挡BIOS被改变为非阻塞

我知道,可以用来制造生物无阻塞但文件说:

Another possible option I have thought about would be to copy the BIO and recreate it, while somehow maintaining all of the state.

解决方案

I did non-blocking SSL connections in my own "lion" code, but I did not use the BIO functionality in OpenSSL at all.

Rather, I went for the callsSSL_set_fd(ctx, fd ) and SSL_get_fd(ssl) to handle my own fdsets and calling select.

The biggest 'gotcha' that took a while to track down was to set SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER and SSL_MODE_ENABLE_PARTIAL_WRITE for it work the way I wanted.

If you want to read the SSL part of the code, it is here:

http://www.lundman.net/cvs/viewvc.cgi/lundman/lion/src/tls.c?revision=1.10&view=markup

这篇关于阻塞到非阻塞模式更改的OpenSSL的BIO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 06:00