Skip to content
Snippets Groups Projects
Commit 4a773328 authored by Anthony Léonard's avatar Anthony Léonard Committed by Guillaume Roguez
Browse files

tls: set errno with gnutls function on Windows


On some platforms, such as Windows, the errno variable is not a
reliable way to send an error code to GnuTLS. A function called
gnutls_transport_set_errno is provided as a better way for push/pull
callbacks to return those error codes to GnuTLS.

We now use it in the push callback which prevent cases where a TLS
session could be terminated due to a misreading of errno by GnuTLS
(especially if an EAGAIN error code is to be returned).

Moreover, as the SIP session MTU is queried during media session setup,
we ensure that the session is still alive at this moment. If not, we
throw a runtime error as it is a nonsense to establish a media
communication if SIP is dead.

Change-Id: Id9220f1b3c7feea72e6ad18481fc039b4b5a2f4e
Reviewed-by: default avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent c1eb1178
Branches
Tags
No related merge requests found
......@@ -524,6 +524,9 @@ TlsSession::sendRaw(const void* buf, size_t size)
stTxRawBytesCnt_ += size;
return ret;
}
// Must be called to pass errno value to GnuTLS on Windows (cf. GnuTLS doc)
gnutls_transport_set_errno(session_, errno);
return -1;
}
......@@ -1113,6 +1116,8 @@ DhParams::generate()
uint16_t
TlsSession::getMtu()
{
if (state_ == TlsSessionState::SHUTDOWN)
throw std::runtime_error("Getting MTU from dead TLS session.");
return gnutls_dtls_get_mtu(session_);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment