feifeiiong opened a new issue #1096:
URL: https://github.com/apache/incubator-brpc/issues/1096
**Describe the bug (描述bug)**
io_buf中处理ssl相关的逻辑,未考虑SSL_write和SSL_read可能出现的所有情况,导致出现异常。
**To Reproduce (复现方法)**
建立ssl连接后,第三方ssl服务端因为某些原因关闭socket,客户端持续写入/读取,框架处理出现异常,出现异常的代码位置:
socket.cpp
1855行,DoRead阶段对ssl的错误码处理。
1699行,DoWrite阶段对ssl的错误码处理。
iobuf.cpp
1665行,append_from_SSL_channel 函数中的SSL_read:
const int rc = SSL_read(ssl, _block->data + _block->size, read_len);
*ssl_error = SSL_get_error(ssl, rc);
rc =0 时,可能收到了close_notify,此时应判断ssl_error,以处理可能的EOF,代码中未见。
此外,也可能出现SSL_ERROR_ZERO_RETURN,也未见处理。
970行:write相关逻辑:
cut_into_SSL_channel函数
const int nw = SSL_write(ssl, r.block->data + r.offset, r.length);
if (nw > 0) {
pop_front(nw);
}
*ssl_error = SSL_get_error(ssl, nw);
未见处理nw = 0,以及相应的ssl error,此处可能socket已关闭。
**Expected behavior (期望行为)**
正确处理SSL相关逻辑。
此外,还有一些疑问:
1. 查看代码发现SSL相关逻辑混用BIO和SSL_read/write 接口,但这种写法似乎不推荐,大佬这么写的原因是?
2. 上述未正确处理的错误,都是通过查看 man的ssl相关api得出,并且实际也遇到了这些问题,当时未处理这些错误的原因是什么?
3.socket.cpp 未调用SSL_shutdown相关逻辑,不调用该函数的原因是?
4.对于一条已经过ssl认证的tcp,从池中再次拿出该socket,为什么需要再次发起握手流程?
**Versions (各种版本)**
OS:
Compiler:
brpc:
protobuf:
**Additional context/screenshots (更多上下文/截图)**
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]