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

Better handling of SSL errors #1523

Merged
merged 2 commits into from
Dec 11, 2019
Merged
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
21 changes: 11 additions & 10 deletions erizo/src/erizo/dtls/DtlsSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,13 @@ void DtlsSocket::forceRetransmit() {

void DtlsSocket::doHandshakeIteration() {
boost::mutex::scoped_lock lock(handshakeMutex_);
char errbuf[1024];
int sslerr;
int ssl_error_code;

if (mHandshakeCompleted)
return;
if (mHandshakeCompleted) {
return;
}

int r = SSL_do_handshake(mSsl);
errbuf[0] = 0;
ERR_error_string_n(ERR_peek_error(), errbuf, sizeof(errbuf));
int return_value = SSL_do_handshake(mSsl);

// See what was written
unsigned char *outBioData;
Expand All @@ -139,17 +137,20 @@ void DtlsSocket::doHandshakeIteration() {
}

// Now handle handshake errors */
switch (sslerr = SSL_get_error(mSsl, r)) {
switch (ssl_error_code = SSL_get_error(mSsl, return_value)) {
case SSL_ERROR_NONE:
mHandshakeCompleted = true;
mSocketContext->handshakeCompleted();
break;
case SSL_ERROR_WANT_READ:
break;
default:
ELOG_ERROR("SSL error %d", sslerr);
ELOG_ERROR("message: SSL error %d", ssl_error_code);
char error_string_buffer[1024];

ERR_error_string_n(ssl_error_code, error_string_buffer, sizeof(error_string_buffer));

mSocketContext->handshakeFailed(errbuf);
mSocketContext->handshakeFailed(error_string_buffer);
// Note: need to fall through to propagate alerts, if any
break;
}
Expand Down