gpt4 book ai didi

c - SSL_read 解密错误代码

转载 作者:太空宇宙 更新时间:2023-11-04 04:28:00 29 4
gpt4 key购买 nike

考虑以下代码,它显示了尝试从 ssl 连接读取 buff_size 字节的尝试。

int bytes = SSL_read(m_ssl, buf, buff_size);
int err = SSL_get_error(m_ssl, bytes);
int err2 = ERR_get_error();

在某些情况下,变量 err 表示上面代码中的有效错误,而 err2 就好像根本没有错误 (=0)。

例如,这是我在测试中遇到的情况:当 SSL_read 尝试读取 0 字节(buffer_size = bytes = 0)时,err 将显示 SSL_ERROR_SYSCALL .但是 err2 仍然是 0,表明没有真正的错误。 SSL_read 返回这个值只是为了表明 0 字节被写入了 buf。

是否还有这样的特殊情况,err 指出可能有问题,但读取结果没有读取错误?

最佳答案

查看the man

SSL_ERROR_SYSCALL

Some I/O error occurred. The OpenSSL error queue may contain more information on the error. If the error queue is empty (i.e. ERR_get_error() returns 0), ret can be used to find out more about the error: If ret == 0, an EOF was observed that violates the protocol. If ret == -1, the underlying BIO reported an I/O error (for socket I/O on Unix systems, consult errno for details).Emphasis mine

关于c - SSL_read 解密错误代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39568646/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com