diff options
Diffstat (limited to 'common/rdr/TLSException.cxx')
-rw-r--r-- | common/rdr/TLSException.cxx | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/common/rdr/TLSException.cxx b/common/rdr/TLSException.cxx index ee4f587b..8c93a3d3 100644 --- a/common/rdr/TLSException.cxx +++ b/common/rdr/TLSException.cxx @@ -22,9 +22,9 @@ #include <config.h> #endif -#include <rdr/TLSException.h> +#include <core/string.h> -#include <rfb/util.h> +#include <rdr/TLSException.h> #include <string.h> #include <stdio.h> @@ -35,11 +35,28 @@ using namespace rdr; #ifdef HAVE_GNUTLS -tls_error::tls_error(const char* s, int err_) noexcept - : std::runtime_error(rfb::format("%s: %s (%d)", s, - gnutls_strerror(err_), err_)), - err(err_) +tls_error::tls_error(const char* s, int err_, int alert_) noexcept + : std::runtime_error(core::format("%s: %s (%d)", s, + strerror(err_, alert_), err_)), + err(err_), alert(alert_) +{ +} + +const char* tls_error::strerror(int err_, int alert_) const noexcept { + const char* msg; + + msg = nullptr; + + if ((alert_ != -1) && + ((err_ == GNUTLS_E_WARNING_ALERT_RECEIVED) || + (err_ == GNUTLS_E_FATAL_ALERT_RECEIVED))) + msg = gnutls_alert_get_name((gnutls_alert_description_t)alert_); + + if (msg == nullptr) + msg = gnutls_strerror(err_); + + return msg; } #endif /* HAVE_GNUTLS */ |