为什么我收到“错误:1409F07F:SSL 例程:SSL3_WRITE_PENDING:错误写入重试”?尝试 SSL_write 时出错?
我在尝试 SSL_write 时是否收到以下错误:
错误:1409F07F:SSL 例程:SSL3_WRITE_PENDING:错误写入重试
Am I getting the following error when attempting an SSL_write:
error:1409F07F:SSL routines:SSL3_WRITE_PENDING: bad write retry
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因非常简单:当 SSL_Write 返回 SSL_ERROR_WANT_WRITE 或 SSL_ERROR_WANT_READ 时,在满足条件(套接字上可用读/写)后,您必须再次使用完全相同的参数重复调用 SSL_write。
使用不同的参数调用它,将产生 1409F07F 错误写入重试错误。
例如,当 ptr = 0xABCDEFGH、size = 4096 的 SSL_write(ssl, ptr, size) 失败并出现 SSL_ERROR_WANT_READ 或 SSL_ERROR_WANT_WRITE 时,重试 SSL_write 调用时,参数 ptr 和 size 应相同。如果 ptr 是指向与原始调用中相同内容的副本的另一个指针,则它不等效。
但是,可以通过设置 SSL_MODE_ENABLE_PARTIAL_WRITE 和/或 SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 来更改 SSL_write 的默认行为。
感谢@ShriramV 的澄清评论,并将其纳入答案
The reason is pretty simple: when SSL_Write returns with SSL_ERROR_WANT_WRITE or SSL_ERROR_WANT_READ, you have to repeat the call to SSL_write with the EXACT same parameters again, after the condition is satisfied (read/write available on the socket).
Calling it with different parameters, will yield the 1409F07F bad write retry error.
For example, when SSL_write(ssl, ptr, size) with ptr = 0xABCDEFGH, size = 4096 fails with SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE, when retrying the SSL_write call, the parameters ptr and size should be same. It is not equivalent if ptr is another pointer pointing to a copy of the same contents as in the original call.
However this default behavior of SSL_write can be changed by setting SSL_MODE_ENABLE_PARTIAL_WRITE and/or SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER.
Thanks for @ShriramV for the clarifying comments, integrated to the answer