<div dir="ltr">On inspecting some code for academic reasons, I noticed that ngx_ssl_shutdown() looks like it might be using SSL_shutdown() incorrectly?<br><br>I haven't actually "used" the code, and have not tested it or seen any symptoms.<div><br></div><div><br></div><div>The first hint of a problem is the following comment:<br><br><div> /* SSL_shutdown() never returns -1, on error it returns 0 */</div></div><div><br></div><div>which does not match the OpenSSL man page very well, or the OpenSSL function ssl3_shutdown() definition.</div><div><br></div><div>Second, it appears that with the way SSL_set_shutdown() is being used to stuff flags into the SSL state, SSL_shutdown() should be called until it returns 1, which may take multiple calls, even if there isn't a WANT_READ or WANT_WRITE condition upon returning -1 (or 0?).  Generally one call is used to send a close_notify, which returns 0 (assuming SSL_set_shutdown hasn't stuffed in <span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.8px;white-space:pre">SSL_RECEIVED_SHUTDOWN)</span>, and further calls wont return 1 until it receives close_notify.</div><div><br></div><div>Quite possibly I am missing some assumptions, which would make good comments in the code.</div><div><br></div><div>I hope this is useful.</div><div><br></div><div>- Judson</div></div>