Re #1994(misc): Avoid calling SSL_shutdown() if handshake wasn't completed otherwise OpenSSL 1.0.2f and newer version will complain. Thanks to Peter Koletzki for the report.

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@5648 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Riza Sulistyo 2017-09-14 05:03:45 +00:00
parent 76ea108e47
commit 98015a8d0b
1 changed files with 8 additions and 1 deletions

View File

@ -1070,7 +1070,14 @@ static void destroy_ssl(pj_ssl_sock_t *ssock)
{
/* Destroy SSL instance */
if (ssock->ossl_ssl) {
SSL_shutdown(ssock->ossl_ssl);
/**
* Avoid calling SSL_shutdown() if handshake wasn't completed.
* OpenSSL 1.0.2f complains if SSL_shutdown() is called during an
* SSL handshake, while previous versions always return 0.
*/
if (SSL_in_init(ssock->ossl_ssl) == 0) {
SSL_shutdown(ssock->ossl_ssl);
}
SSL_free(ssock->ossl_ssl); /* this will also close BIOs */
ssock->ossl_ssl = NULL;
}