From 69c600bd8510c3ec94f1f4ca8557e42832d6c142 Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Mon, 19 Apr 2021 15:24:45 +0300 Subject: mhd_send: added TLS-specific error code --- src/microhttpd/connection.c | 2 ++ src/microhttpd/connection.h | 5 +++++ src/microhttpd/mhd_send.c | 12 ++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index baf0fcb4..3eaa2935 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c @@ -152,6 +152,8 @@ str_conn_error_ (ssize_t mhd_err_code) return _ ("Argument value is not supported"); case MHD_ERR_PIPE_: return _ ("The socket is no longer available for sending"); + case MHD_ERR_TLS_: + return _ ("TLS encryption or decryption error"); default: break; /* Mute compiler warning */ } diff --git a/src/microhttpd/connection.h b/src/microhttpd/connection.h index f7d7b17a..b21029e6 100644 --- a/src/microhttpd/connection.h +++ b/src/microhttpd/connection.h @@ -71,6 +71,11 @@ */ #define MHD_ERR_PIPE_ (-3080) +/** + * General TLS encryption or decryption error + */ +#define MHD_ERR_TLS_ (-4097) + /** * Set callbacks for this connection to those for HTTP. diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index 049034c9..a9f2b484 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c @@ -788,8 +788,16 @@ MHD_send_data_ (struct MHD_Connection *connection, if (GNUTLS_E_INTERRUPTED == ret) return MHD_ERR_AGAIN_; if ( (GNUTLS_E_ENCRYPTION_FAILED == ret) || - (GNUTLS_E_INVALID_SESSION == ret) ) - return MHD_ERR_INVAL_; + (GNUTLS_E_INVALID_SESSION == ret) || + (GNUTLS_E_COMPRESSION_FAILED == ret) || + (GNUTLS_E_EXPIRED == ret) || + (GNUTLS_E_HASH_FAILED == ret) ) + return MHD_ERR_TLS_; + if ( (GNUTLS_E_PUSH_ERROR == ret) || + (GNUTLS_E_INTERNAL_ERROR == ret) || + (GNUTLS_E_CRYPTODEV_IOCTL_ERROR == ret) || + (GNUTLS_E_CRYPTODEV_DEVICE_ERROR == ret) ) + return MHD_ERR_PIPE_; if (GNUTLS_E_PREMATURE_TERMINATION == ret) return MHD_ERR_CONNRESET_; if (GNUTLS_E_MEMORY_ERROR == ret) -- cgit v1.2.3