#1605: try to do a proper SSL_shutdown()

This commit is contained in:
Guenter Obiltschnig 2017-02-22 21:42:02 +01:00
parent 915b9ed890
commit b2477e4c94

View File

@ -219,14 +219,20 @@ void SecureSocketImpl::shutdown()
bool shutdownSent = (shutdownState & SSL_SENT_SHUTDOWN) == SSL_SENT_SHUTDOWN;
if (!shutdownSent)
{
// A proper clean shutdown would require us to
// retry the shutdown if we get a zero return
// value, until SSL_shutdown() returns 1.
// However, this will lead to problems with
// most web browsers, so we just set the shutdown
// flag by calling SSL_shutdown() once and be
// done with it.
// A proper clean shutdown requires us to
// call SSL_shutdown() a second time if the
// first call returns 0.
// Previously, this lead to problems with
// most web browsers, so we just called
// SSL_shutdown() once.
// It seems that behavior has changed in newer
// OpenSSL and/or browser versions, and things
// seem to work better now.
int rc = SSL_shutdown(_pSSL);
if (rc == 0 && _pSocket->getBlocking())
{
rc = SSL_shutdown(_pSSL);
}
if (rc < 0) handleError(rc);
if (_pSocket->getBlocking())
{