Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SSL to continue decrypting data after renego completes #4234

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pjlib/src/pj/ssl_sock_imp_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,11 @@ static pj_bool_t ssock_on_data_read (pj_ssl_sock_t *ssock,
"Failed to flush delayed send"));
goto on_error;
}

/* If renego has been completed, continue reading data */
if (status == PJ_SUCCESS)
continue;

} else if (status != PJ_EPENDING) {
PJ_PERROR(1,(ssock->pool->obj_name, status,
"Renegotiation failed"));
Expand Down
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
Loading