SSL_shutdown上的openssl文档指出:因此,如果双向关闭尚未完成(第一次调用的返回值为0),建议检查SSL_shutdown()的返回值并再次调用SSL_shutdown().
https://www.openssl.org/docs/ssl/SSL_shutdown.html
我在下面有一个代码片段,我从SSL_shutdown检查返回值0并再次调用它,我一直在使用它.我的问题是,可以忽略第二次调用时SSL_shutdown的返回值,或者我们应该继续重试SSL_shutdown,直到返回1(双向关闭完成).
int r = SSL_shutdown(ssl);
//error handling here if r < 0
if(!r)
{
shutdown(fd,1);
SSL_shutdown(ssl); //how should I handle return value and error handling here is it required??
}
SSL_free(ssl);
SSLMap.erase(fd);
shutdown(fd,2);
close(fd);
Run Code Online (Sandbox Code Playgroud)