正确处理SSL_shutdown

问题描述 投票:9回答:1

关于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);

关于SSL_shutdown的openssl文档指出:因此,如果尚未进行双向关闭,建议检查SSL_shutdown()的返回值并再次调用SSL_shutdown()...

c++ c openssl
1个回答
12
投票

[openssl

© www.soinside.com 2019 - 2024. All rights reserved.