为什么我收到“错误:1409F07F:SSL 例程:SSL3_WRITE_PENDING:写重试错误"?尝试 SSL_write 时出错? [英] Why am I getting "error:1409F07F:SSL routines:SSL3_WRITE_PENDING: bad write retry" error while attempting an SSL_write?
问题描述
我在尝试 SSL_write 时是否收到以下错误:
Am I getting the following error when attempting an SSL_write:
错误:1409F07F:SSL 例程:SSL3_WRITE_PENDING:重试写入错误
error:1409F07F:SSL routines:SSL3_WRITE_PENDING: bad write retry
推荐答案
原因很简单:当 SSL_Write 返回 SSL_ERROR_WANT_WRITE 或 SSL_ERROR_WANT_READ 时,您必须再次使用完全相同的参数再次调用 SSL_write,条件为满意(在套接字上可以读/写).
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).
使用不同的参数调用它,将产生 1409F07F 错误写入重试错误.
Calling it with different parameters, will yield the 1409F07F bad write retry error.
例如,当 SSL_write(ssl, ptr, size) with ptr = 0xABCDEFGH, size = 4096 因 SSL_ERROR_WANT_READ 或 SSL_ERROR_WANT_WRITE 而失败时,当重试 SSL_write 调用时,参数 ptr 和 size 应该相同.如果 ptr 是另一个指向与原始调用中相同内容的副本的指针,则它是不等价的.
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.
但是,可以通过设置 SSL_MODE_ENABLE_PARTIAL_WRITE 和/或 SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 来更改 SSL_write 的默认行为.
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.
感谢@ShriramV 的澄清评论,并整合到答案中
Thanks for @ShriramV for the clarifying comments, integrated to the answer
这篇关于为什么我收到“错误:1409F07F:SSL 例程:SSL3_WRITE_PENDING:写重试错误"?尝试 SSL_write 时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!