-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSL 相关问题。 #1096
Comments
这个问题有什么进展吗,各位大佬? |
|
感谢您的回复!第四点确实是如您所说。关于1,3点,有一些不同的看法: '>' 0 0 The read operation was not successful. The reason may either be a clean shutdown due to a "close notify" alert sent by the peer (in which case the SSL_RECEIVED_SHUTDOWN flag in the ssl shutdown state is set (see ssl_shutdown(3), ssl_set_shutdown(3)). It is also possible, that the peer simply shut down the underlying transport and the shutdown is incomplete. Call SSL_get_error() with the return value ret to find out, whether an error occurred or the connection was shut down cleanly ( SSL_ERROR_ZERO_RETURN SSL_get_error Return Values: 在iobuf中是这样处理的:
在rc == 0时,返回,并置错误码,此处的错误码,有可能是SSL_ERROR_SYSCALL/SSL_ERROR_ZERO_RETURN, 在socket.cpp:
如上,以上错误码被default捕获,而此刻nr 有可能!=0 (iobuf.cpp : return (nr > 0 ? nr : rc);), 从而导致该EOF被忽略,导致socket无法关闭。在实际应用中,该问题已经频繁被触发,打印日志类似: |
另外,关于main socket,健康检查时,如果设置了SSL options,会尝试进行ssl连接。想问下这个操作是否有必要? |
感谢指正,我看了下 DoRead中确实存在bug,但具体问题好像与你描述的不同:
因此,我这边看这个bug主要在于会错误打印一句warning日志,应该不影响fd关闭或者fd泄漏 另外,SSL握手目前被视作一种连通性指标,如果server拒绝与client建立SSL(无论何种因素),那么后续任何请求肯定无法成功。 |
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相关逻辑。
此外,还有一些疑问:
Versions (各种版本)
OS:
Compiler:
brpc:
protobuf:
Additional context/screenshots (更多上下文/截图)
The text was updated successfully, but these errors were encountered: