如何清理错误的 OpenSSL 连接
如果对 SSL_accept 的调用失败,我只想退出。
目前我先调用 SSL_shutdown,然后调用 SSL_free,但自从实现此操作以来,两个客户在 OpenSSL 中发生了深度崩溃(稍后调用 SSL_accept 时),所以我猜测这可能不是清理的最佳方法。
文档说 SSL_shutdown 用于正确清理,并且可能需要调用两次(尽管如果 SSL_accept 失败,我不认为会出现这种情况)。 SSL_clear 是另一个选项,但它似乎更像是连接重置。
SSL_free 递减引用计数并在引用计数达到 0 时删除连接。我知道我的代码没有任何引用,但“会话”可能有吗?
是否有一种明确的方法可以使用 OpenSSL 完全关闭/关闭/释放 SSL 对象?
If a call to SSL_accept fails, I want to just bail out.
Currently I'm calling SSL_shutdown and then SSL_free, but since implementing this, two customers have had crashes deep down in OpenSSL (when calling SSL_accept at a later time), so I'm guessing maybe this isn't the best way to clean up.
The docs say SSL_shutdown is used to correctly cleanup, and it might need to be called twice (although if SSL_accept failed, I wouldn't think that would be the case). SSL_clear is another option, but it seems like more of a connection reset.
SSL_free decrements a reference count and deletes the connection if the reference count hits 0. I know my code doesn't have any references, but the 'session' might?
Is there a definitive way for completely closing/shutting down/freeing an SSL object with OpenSSL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦您对
SSL
对象调用了SSL_free()
,就不应再使用它。您需要确保为后续的SSL_accept()
使用SSL_new()
创建新的 SSL。Once you've called
SSL_free()
on theSSL
object, you shouldn't use it again. You need to ensure that a new SSL is created withSSL_new()
for the subsequentSSL_accept()
.