【发布时间】:2014-07-31 03:35:17
【问题描述】:
在我的 ActiveUpdate 模块中(从服务器下载文件),如果服务器丢弃 FIN 包,关闭 OpenSSL 连接将挂起(等待超过 2 小时)。
SSL连接关闭伪代码
def ssl_close():
if (!SSL_shutdown(m_ssl)):
…
shutdown(SSL_get_fd(m_ssl), SHUT_WR);
SSL_shutdown(m_ssl)
...
挂起连接的netstat输出
tcp 0 0 192.168.133.135:52453 10.203.136.169:4122 FIN_WAIT2 off (0.00/0/0)
https://www.openssl.org/docs/ssl/SSL_shutdown.html
为了完成双向关闭握手,必须再次调用 SSL_shutdown()。 如果底层 BIO 阻塞,SSL_shutdown() 只会在握手步骤完成或发生错误后返回。
如果调用一次SSL_shutdown()就不会死机,对内存和连接资源有影响吗?
是否有超时机制来控制 OpenSSL 中的 SSL_shutdown() 或更好的方法?
【问题讨论】:
标签: ssl