1. SSL_MODE_AUTO_RETRY的作用
关于这个flag的作用,openSSL官方的解释如下所示:
SSL_MODE_AUTO_RETRY
Never bother the application with retries if the transport is blocking. If a renegotiation take place during normal operation, a **SSL_read(3)**or SSL_write(3) would return with -1 and indicate the need to retry with SSL_ERROR_WANT_READ. In a non-blocking environment applications must be prepared to handle incomplete read/write operations. In a blocking environment, applications are not always prepared to deal with read/write operations returning without success report. The flag SSL_MODE_AUTO_RETRY will cause read/write operations to only return after the handshake and successful completion.
这个flag实际的作用SSL_read 和SSL_write两个函数会在握手并且完成读写操作操作之后返回。
因此这个flag被设置到SSL的CTX之后,如果程序中使用了多路复用机制(例如select poll等)来触发读操作。那么如果对端开始和本地进行重协商时,本地fd会由于有数据报文到达,从而相关的链接被认为有数据需要读取,程序调用SSL_read进行fd的读写,然后在SSL_read内部完成TLS的重协商(所谓重协商可以理解为一次重新握手动作)。但是重协商完成之后,如果对端没有发送数据,那么将导致SSL_read无法返回,一直blocking在SSL_read函数中。
综上,如果使用了多路复用机制,那么最好就不要再使用SSL_MODE_AUTO_RETRY参数,否则可能导致对端进行TLS重协商时出现SSL_read无法返回的问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)