On Sun, 15 Nov 2026 14:23:53 +0100,
Gleydson Soares <[email protected]> wrote:
> 
> 
> > 
> > I'd like to point that since this update I can't use checkHost.
> > 
> > It fails like this:
> > 
> > [!] /etc/stunnel/stunnel.conf:78: "checkHost = imap.gmail.com": Specified 
> > option name is not valid here
> > 
> > 
> > -- 
> > wbr, Kirill
> 
> 
> Looks like newer stunnel 5.83 ships with a bugfix for
> 
> From https://www.stunnel.org/NEWS.html 
> 
> "Re-enabled the "checkHost", "checkEmail", and "checkIP" options with 
> LibreSSL, 
> which has long supported the underlying X.509 name checking API (thanks to 
> Masahito Yamaga)”
> 
> 
> Not yet released though. 
> 
> 

Yes, 5.83b2 works as expected.

I had moved forward and minimized the diff bethween 5.82 and 5.83b2 to only
libressl specific.

Brifly tested and it works on my end.

Shall we go this in? Shall we wait till 5.83 is released?

Index: Makefile
===================================================================
RCS file: /home/cvs/ports/security/stunnel/Makefile,v
diff -u -p -r1.101 Makefile
--- Makefile    11 Nov 2026 23:20:38 -0000      1.101
+++ Makefile    15 Nov 2026 13:58:18 -0000
@@ -1,6 +1,7 @@
 COMMENT=       SSL encryption wrapper for standard network daemons
 
 DISTNAME=      stunnel-5.82
+REVISION=      0
 CATEGORIES=    security
 
 MAINTAINER=    Gleydson Soares <[email protected]>
Index: patches/patch-src_ctx_c
===================================================================
RCS file: patches/patch-src_ctx_c
diff -N patches/patch-src_ctx_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_ctx_c     15 Nov 2026 13:59:12 -0000
@@ -0,0 +1,21 @@
+Index: src/ctx.c
+--- src/ctx.c.orig
++++ src/ctx.c
+@@ -149,7 +149,7 @@ NOEXPORT void session_cache_save(CLI *c, SSL_SESSION *
+ NOEXPORT SSL_SESSION *SSL_SESSION_dup(SSL_SESSION *src);
+ #endif
+ NOEXPORT SSL_SESSION *sess_get_cb(SSL *ssl,
+-#if OPENSSL_VERSION_NUMBER>=0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
++#if OPENSSL_VERSION_NUMBER>=0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+     const
+ #endif
+     unsigned char *key, int key_len, int *do_copy);
+@@ -2145,7 +2145,7 @@ NOEXPORT SSL_SESSION *SSL_SESSION_dup(SSL_SESSION *src
+ #endif
+ 
+ NOEXPORT SSL_SESSION *sess_get_cb(SSL *ssl,
+-#if OPENSSL_VERSION_NUMBER>=0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
++#if OPENSSL_VERSION_NUMBER>=0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+         const
+ #endif
+         unsigned char *key, int key_len, int *do_copy) {
Index: patches/patch-src_options_c
===================================================================
RCS file: patches/patch-src_options_c
diff -N patches/patch-src_options_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_options_c 15 Nov 2026 13:59:12 -0000
@@ -0,0 +1,56 @@
+Index: src/options.c
+--- src/options.c.orig
++++ src/options.c
+@@ -112,6 +112,7 @@ NOEXPORT const char *parse_service_option(CMD cmd,
+ 
+ #ifndef OPENSSL_NO_TLSEXT
+ NOEXPORT const char *sni_init(SERVICE_OPTIONS *section);
++NOEXPORT int sni_ip_literal(const char *name);
+ #endif /* !defined(OPENSSL_NO_TLSEXT) */
+ 
+ #if OPENSSL_VERSION_NUMBER>=0x10100000L
+@@ -1964,7 +1965,7 @@ NOEXPORT const char *parse_service_option(CMD cmd, SER
+         break;
+     }
+ 
+-#if OPENSSL_VERSION_NUMBER>=0x10002000L && !defined(LIBRESSL_VERSION_NUMBER)
++#if OPENSSL_VERSION_NUMBER>=0x10002000L
+ 
+     /* checkEmail */
+     switch(cmd) {
+@@ -4501,7 +4502,7 @@ NOEXPORT const char *parse_service_option(CMD cmd, SER
+         return option_not_found;
+     case CMD_INITIALIZE:
+ #ifndef USE_DTLS
+-        if(section->sock_type==SOCK_DGRAM)
++        if(socket_type_is_datagram(section->sock_type))
+             return "DTLS is not supported by this OpenSSL build";
+ #endif /* !defined(USE_DTLS) */
+         if(section!=&new_service_options) { /* daemon mode checks */
+@@ -4599,9 +4600,26 @@ NOEXPORT const char *sni_init(SERVICE_OPTIONS *section
+                 str_free(section->sni);
+                 section->sni=str_dup_detached("localhost");
+             }
++            /* RFC 6066 does not permit IP literals in SNI, and LibreSSL
++             * rejects them instead of ignoring them */
++            if(sni_ip_literal(section->sni)) {
++                s_log(LOG_INFO,
++                    "Not setting SNI for an IP address: %s", section->sni);
++                str_free(section->sni);
++            }
+         }
+     }
+     return NULL;
++}
++
++/* whether the name is an IP literal, which RFC 6066 forbids in SNI */
++NOEXPORT int sni_ip_literal(const char *name) {
++    if(strchr(name, ':')) /* IPv6 literal (the port has been stripped) */
++        return 1;
++    /* MISRA 7.2 deviation: the INADDR_NONE header macro is an unsigned
++     * sentinel defined without a suffix. */
++    /* cppcheck-suppress misra-c2012-7.2 */
++    return inet_addr(name)!=INADDR_NONE;
+ }
+ 
+ #endif /* !defined(OPENSSL_NO_TLSEXT) */
Index: patches/patch-src_ssl_c
===================================================================
RCS file: patches/patch-src_ssl_c
diff -N patches/patch-src_ssl_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_ssl_c     15 Nov 2026 13:59:12 -0000
@@ -0,0 +1,12 @@
+Index: src/ssl.c
+--- src/ssl.c.orig
++++ src/ssl.c
+@@ -287,6 +287,8 @@ NOEXPORT int cb_dup_addr(CRYPTO_EX_DATA *to, CRYPTO_EX
+     (void)argl; /* squash the unused parameter warning */
+     (void)argp; /* squash the unused parameter warning */
+     src=*(void **)from_d;
++    if(!src) /* no address was cached in the source session */
++        return 1;
+     len=sockaddr_len(src);
+     dst=str_alloc_detached((size_t)len);
+     (void)memcpy(dst, src, (size_t)len);
Index: patches/patch-src_str_c
===================================================================
RCS file: patches/patch-src_str_c
diff -N patches/patch-src_str_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_str_c     15 Nov 2026 13:59:12 -0000
@@ -0,0 +1,21 @@
+Index: src/str.c
+--- src/str.c.orig
++++ src/str.c
+@@ -256,10 +256,15 @@ void str_init(void) {
+ 
+         hook_result=CRYPTO_set_mem_functions(str_alloc_detached_debug,
+             str_realloc_detached_debug, str_free_debug);
+-#if !defined(LIBRESSL_VERSION_NUMBER)
+-        if(!hook_result)
++        if(!hook_result) {
++#if defined(LIBRESSL_VERSION_NUMBER)
++            /* LibreSSL rejects OpenSSL allocator hooks */
++            s_log(LOG_WARNING,
++                "CRYPTO_set_mem_functions failed: leak detection disabled");
++#else
+             fatal("CRYPTO_set_mem_functions failed");
+ #endif
++        }
+     }
+ #else
+     CRYPTO_set_mem_ex_functions(str_alloc_detached_debug,


-- 
wbr, Kirill

Reply via email to