Skip to content

Commit

Permalink
Update SSL socket with OpenSSL backend to return PJ_EEOF only when re…
Browse files Browse the repository at this point in the history
…negotiation is needed (or not completed).
  • Loading branch information
nanangizz committed Dec 25, 2024
1 parent c9c385d commit 5bb2d60
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pjlib/src/pj/ssl_sock_ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2476,7 +2476,9 @@ static pj_status_t ssl_read(pj_ssl_sock_t *ssock, void *data, int *size)
/* SSL might just return SSL_ERROR_WANT_READ in
* re-negotiation.
*/
if (err != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ) {
if (err != SSL_ERROR_NONE && err != SSL_ERROR_WANT_READ &&
err != SSL_ERROR_ZERO_RETURN)
{
if (err == SSL_ERROR_SYSCALL && size_ == -1 &&
ERR_peek_error() == 0 && errno == 0)
{
Expand All @@ -2499,9 +2501,11 @@ static pj_status_t ssl_read(pj_ssl_sock_t *ssock, void *data, int *size)
}
}

pj_lock_release(ssock->write_mutex);
/* Need renegotiation */
return PJ_EEOF;
/* Return PJ_EEOF when SSL needs renegotiation */
if (!SSL_is_init_finished(ossock->ossl_ssl)) {
pj_lock_release(ssock->write_mutex);
return PJ_EEOF;
}
}

pj_lock_release(ssock->write_mutex);
Expand Down

0 comments on commit 5bb2d60

Please sign in to comment.