From 34ff8f11ae4bb704dafd65b6fbf99793254419ee Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Mon, 20 Jan 2025 12:00:36 +0100 Subject: [PATCH] Public API: added new data type for TLS sessions --- src/include/microhttpd2.h | 41 +++++++++++++++++++++++++------ src/include/microhttpd2_main.h.in | 41 +++++++++++++++++++++++++------ 2 files changed, 66 insertions(+), 16 deletions(-) diff --git a/src/include/microhttpd2.h b/src/include/microhttpd2.h index 01a8a5ea..6ff75f2b 100644 --- a/src/include/microhttpd2.h +++ b/src/include/microhttpd2.h @@ -9708,6 +9708,35 @@ enum MHD_FIXED_ENUM_MHD_SET_ MHD_TlsVersion MHD_TLS_VERSION_UNKNOWN = 1999 }; +/** + * Connection TLS session information. + * Only one member is valid. Use #MHD_DAEMON_INFO_FIXED_TLS_TYPE to find out + * which member should be used. + */ +union MHD_ConnInfoDynamicTlsSess +{ + /* Include before this header to get a better type safety */ + /** + * GnuTLS session handle, of type "gnutls_session_t". + */ +#if defined(GNUTLS_VERSION_MAJOR) && GNUTLS_VERSION_MAJOR >= 3 + gnutls_session_t v_gnutls_session; +#else + void * /* gnutls_session_t */ v_gnutls_session; +#endif + + /* Include or before this header to get + a better type safety */ + /** + * OpenSSL session handle, of type "SSL*". + */ +#if defined(OPENSSL_TYPES_H) && OPENSSL_VERSION_MAJOR >= 3 + SSL *v_openssl_session; +#else + void /* SSL */ *v_openssl_session; +#endif +}; + /** * Information about a connection. */ @@ -9738,16 +9767,12 @@ union MHD_ConnectionInfoDynamicData */ enum MHD_TlsVersion v_tls_ver; - /* Include before this header to get a better type safety */ /** - * GnuTLS session handle, of type "gnutls_session_t". + * Connection TLS session information. + * Only one member is valid. Use #MHD_DAEMON_INFO_FIXED_TLS_TYPE to find out + * which member should be used. */ -#if defined(GNUTLS_VERSION_MAJOR) && GNUTLS_VERSION_MAJOR >= 3 - gnutls_session_t -#else - void * /* gnutls_session_t */ -#endif - v_gnutls_session; + union MHD_ConnInfoDynamicTlsSess v_tls_session; }; /** diff --git a/src/include/microhttpd2_main.h.in b/src/include/microhttpd2_main.h.in index b1ba7d91..f28fe434 100644 --- a/src/include/microhttpd2_main.h.in +++ b/src/include/microhttpd2_main.h.in @@ -5086,6 +5086,35 @@ enum MHD_FIXED_ENUM_MHD_SET_ MHD_TlsVersion MHD_TLS_VERSION_UNKNOWN = 1999 }; +/** + * Connection TLS session information. + * Only one member is valid. Use #MHD_DAEMON_INFO_FIXED_TLS_TYPE to find out + * which member should be used. + */ +union MHD_ConnInfoDynamicTlsSess +{ + /* Include before this header to get a better type safety */ + /** + * GnuTLS session handle, of type "gnutls_session_t". + */ +#if defined(GNUTLS_VERSION_MAJOR) && GNUTLS_VERSION_MAJOR >= 3 + gnutls_session_t v_gnutls_session; +#else + void * /* gnutls_session_t */ v_gnutls_session; +#endif + + /* Include or before this header to get + a better type safety */ + /** + * OpenSSL session handle, of type "SSL*". + */ +#if defined(OPENSSL_TYPES_H) && OPENSSL_VERSION_MAJOR >= 3 + SSL *v_openssl_session; +#else + void /* SSL */ *v_openssl_session; +#endif +}; + /** * Information about a connection. */ @@ -5116,16 +5145,12 @@ union MHD_ConnectionInfoDynamicData */ enum MHD_TlsVersion v_tls_ver; - /* Include before this header to get a better type safety */ /** - * GnuTLS session handle, of type "gnutls_session_t". + * Connection TLS session information. + * Only one member is valid. Use #MHD_DAEMON_INFO_FIXED_TLS_TYPE to find out + * which member should be used. */ -#if defined(GNUTLS_VERSION_MAJOR) && GNUTLS_VERSION_MAJOR >= 3 - gnutls_session_t -#else - void * /* gnutls_session_t */ -#endif - v_gnutls_session; + union MHD_ConnInfoDynamicTlsSess v_tls_session; }; /**