Skip to contentSkip to conversation

package/libuhttpd: fix build w/ mbedtls v3.6

PATCH Applied Thomas Perale via buildroot 1 participant 4 messages Jul 6, 2025 – Jul 11, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/libuhttpd: fix build w/ mbedtls v3.6

Since the mbedtls bump to v3.6 [1] the libuhttpd fails to build with the following error:

```
[  8%] Building C object src/ssl/CMakeFiles/xssl.dir/mbedtls.c.o
.../buildroot/output/build/libuhttpd-3.14.1/src/ssl/mbedtls.c:52:10: fatal error: mbedtls/certs.h: No such file or directory
   52 | #include <mbedtls/certs.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
```

This error can be reproduced with the following config:

```
cat <<EOF >.config
BR2_arm=y
BR2_cortex_a7=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_MBEDTLS=y
BR2_PACKAGE_LIBUHTTPD=y
EOF
make olddefconfig
make
```

The compatibility with mbedtls v3 has been addressed upstream in the zhaojh329/ssl project included as a submodule of libuhttpd [2].

This patch backport this upstream commit to be applied on the submodule directory. This required adaptation of the line numbers (see [3]) and renaming a function reference passed as parameter of 'mbedtls_pk_parse_keyfile' caused by the commit [4].

[1] 3481a9643f package/mbedtls: bump to version 3.6.3.1
[2] https://github.com/zhaojh329/ssl/commit/28cc9b5d98179d161673d20e79333ae5a4864228
[3] https://github.com/zhaojh329/ssl/commit/8092b5a490eedeb042cc1036ebeab6442624cf4c#diff-fbc46fa2db83f8649ccf1f46c6a044473b7b228edc7d4c0f7cc04b5a879f6fb7
[4] https://github.com/zhaojh329/ssl/commit/0e7d2f73d769cc4ddb350381cebb5ef6f27ab653#diff-fbc46fa2db83f8649ccf1f46c6a044473b7b228edc7d4c0f7cc04b5a879f6fb7R92

---
 ...dd-compatibility-with-mbed-tls-3-0-0.patch | 64 +++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 package/libuhttpd/0004-add-compatibility-with-mbed-tls-3-0-0.patch
package/libuhttpd/0004-add-compatibility-with-mbed-tls-3-0-0.patch new file +64 -0
new file mode 100644
index 0000000000..1f45d4634c
@@ -0,0 +1,64 @@
+From 28cc9b5d98179d161673d20e79333ae5a4864228 Mon Sep 17 00:00:00 2001
+From: Jianhui Zhao <[email protected]>
+Date: Sat, 4 May 2024 19:40:07 +0800
+Subject: [PATCH] Add compatibility with Mbed TLS 3.0.0
+
+Signed-off-by: Jianhui Zhao <[email protected]>
+Upstream: https://github.com/zhaojh329/ssl/commit/28cc9b5d98179d161673d20e79333ae5a4864228
+[thomas: 
+  - Apply to submodule directory
+  - Rename 'urandom' to '_urandom'
+  - Adapt line numbers
+]
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ src/ssl/mbedtls.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/src/ssl/mbedtls.c b/src/ssl/mbedtls.c
+index 2e02e1c..cad7e00 100644
+--- a/src/ssl/mbedtls.c
++++ b/src/ssl/mbedtls.c
+@@ -49,7 +49,6 @@
+ #include "ssl.h"
+ 
+ #include <mbedtls/ssl.h>
+-#include <mbedtls/certs.h>
+ #include <mbedtls/x509.h>
+ #include <mbedtls/rsa.h>
+ #include <mbedtls/error.h>
+@@ -136,9 +135,13 @@ static const int default_ciphersuites_client[] =
+     AES_CBC_CIPHERS(ECDHE_ECDSA),
+     AES_CBC_CIPHERS(ECDHE_RSA),
+     AES_CBC_CIPHERS(DHE_RSA),
++#ifdef MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
+     MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,
++#endif
+     AES_CIPHERS(RSA),
++#ifdef MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA
+     MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA,
++#endif
+     0
+ };
+ 
+@@ -221,7 +224,7 @@ static void ssl_update_own_cert(struct ssl_context *ctx)
+     if (!ctx->cert.version)
+         return;
+ 
+-    if (!ctx->key.pk_info)
++    if (mbedtls_pk_get_type(&ctx->key) == MBEDTLS_PK_NONE)
+         return;
+ 
+     mbedtls_ssl_conf_own_cert(&ctx->conf, &ctx->cert, &ctx->key);
+@@ -258,7 +261,11 @@ int ssl_load_key_file(struct ssl_context *ctx, const char *file)
+ {
+     int ret;
+ 
++#if (MBEDTLS_VERSION_NUMBER >= 0x03000000)
++    ret = mbedtls_pk_parse_keyfile(&ctx->key, file, NULL, _urandom, NULL);
++#else
+     ret = mbedtls_pk_parse_keyfile(&ctx->key, file, NULL);
++#endif
+     if (ret)
+         return -1;
+ 
Signature · 6 lines
2.50.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/2 package/libuhttpd: bump to v3.14.2

For more information see the release note:
- https://github.com/zhaojh329/libuhttpd/releases/tag/v3.14.2

---
 .checkpackageignore                           |  1 -
 ...01-add-compatibility-for-wolfssl-5-0.patch | 30 ---------
 .../0002-compatibility-for-openssl-3.0.patch  | 31 ---------
 ...akeLists.txt-add-BUILD_WERROR-option.patch | 30 ---------
 ...dd-compatibility-with-mbed-tls-3-0-0.patch | 64 -------------------
 package/libuhttpd/libuhttpd.hash              |  2 +-
 package/libuhttpd/libuhttpd.mk                |  2 +-
 7 files changed, 2 insertions(+), 158 deletions(-)
 delete mode 100644 package/libuhttpd/0001-add-compatibility-for-wolfssl-5-0.patch
 delete mode 100644 package/libuhttpd/0002-compatibility-for-openssl-3.0.patch
 delete mode 100644 package/libuhttpd/0003-CMakeLists.txt-add-BUILD_WERROR-option.patch
 delete mode 100644 package/libuhttpd/0004-add-compatibility-with-mbed-tls-3-0-0.patch
.checkpackageignore +0 -1
index dbe0963ca2..9abfd531f4 100644
@@ -712,7 +712,6 @@ package/libtomcrypt/0001-fix-CVE-2019-17362.patch lib_patch.Upstream
 package/libtommath/0001-Build-test-bn_mp_set_double-c-on-more-platforms.patch lib_patch.Upstream
 package/libtorrent/0001-libtorrent.pc.in-add-Libs.Private.patch lib_patch.Upstream
 package/libubootenv/0001-src-CMakeLists.txt-do-not-force-the-build-of-a-share.patch lib_patch.Upstream
-package/libuhttpd/0001-add-compatibility-for-wolfssl-5-0.patch lib_patch.Upstream
 package/libuio/0001-configure.ac-set-automake-strictness-to-foreign.patch lib_patch.Upstream
 package/liburcu/0001-Only-blacklist-ARM-gcc-4.8.0-and-4.8.1.patch lib_patch.Upstream
 package/libvpx/0001-vpx_mem-vpx_mem.h-Fix-compilation-with-uClibc.patch lib_patch.Upstream
package/libuhttpd/0001-add-compatibility-for-wolfssl-5-0.patch deleted +0 -30
deleted file mode 100644
index 7da7199e7e..0000000000
@@ -1,30 +0,0 @@
-From 73aa4ef762b2de67bc8c7c260bd36b34fdb91e63 Mon Sep 17 00:00:00 2001
-From: "Sergey V. Lobanov" <[email protected]>
-Date: Mon, 3 Jan 2022 19:36:52 +0300
-Subject: [PATCH] add compatibility for wolfssl >= 5.0
-
-NTRU support has been removed in wolfssl 5.0 so it is required to
-mask NTRU specific code if wolfssl >= 5.0
-
-Signed-off-by: Sergey V. Lobanov <sergey at lobanov.in>
-[Retrieved from:
-https://github.com/zhaojh329/ssl/commit/73aa4ef762b2de67bc8c7c260bd36b34fdb91e63]
-Signed-off-by: Fabrice Fontaine <[email protected]>
----
- openssl.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/src/ssl/openssl.c b/src/ssl/openssl.c
-index 5a49267..278bab5 100644
---- a/src/ssl/openssl.c
-+++ b/src/ssl/openssl.c
-@@ -336,7 +336,9 @@ static bool handle_wolfssl_asn_error(void *ssl, int r,
-     case ASN_SIG_HASH_E:
-     case ASN_SIG_KEY_E:
-     case ASN_DH_KEY_E:
-+#if LIBWOLFSSL_VERSION_HEX < 0x05000000
-     case ASN_NTRU_KEY_E:
-+#endif
-     case ASN_CRIT_EXT_E:
-     case ASN_ALT_NAME_E:
-     case ASN_NO_PEM_HEADER:
package/libuhttpd/0002-compatibility-for-openssl-3.0.patch deleted +0 -31
deleted file mode 100644
index 484d472bad..0000000000
@@ -1,31 +0,0 @@
-From d93e6426ec1d8c019bd302e4599f3b91ba95fb3b Mon Sep 17 00:00:00 2001
-From: Jianhui Zhao <[email protected]>
-Date: Fri, 29 Apr 2022 23:47:31 +0800
-Subject: [PATCH] compatibility for openssl >= 3.0
-
-Signed-off-by: Jianhui Zhao <[email protected]>
-
-Upstream: https://github.com/zhaojh329/ssl/commit/d93e6426ec1d8c019bd302e4599f3b91ba95fb3b
-
-Signed-off-by: Bernd Kuhls <[email protected]>
----
- openssl.c | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/openssl.c b/openssl.c
-index 278bab5..2169db1 100644
---- a/src/ssl/openssl.c
-+++ b/src/ssl/openssl.c
-@@ -139,8 +139,11 @@ const char *ssl_last_error_string(char *buf, int len)
- 
-     if (ssl_err_code == SSL_ERROR_SSL) {
-         int used;
--
-+#if OPENSSL_VERSION_MAJOR < 3
-         ssl_err_code = ERR_peek_error_line_data(&file, &line, &data, &flags);
-+#else
-+        ssl_err_code = ERR_peek_error_all(&file, &line, NULL, &data, &flags);
-+#endif
-         ERR_error_string_n(ssl_err_code, buf, len);
- 
-         used = strlen(buf);
package/libuhttpd/0003-CMakeLists.txt-add-BUILD_WERROR-option.patch deleted +0 -30
deleted file mode 100644
index 2e87014e87..0000000000
@@ -1,30 +0,0 @@
-From c0f2260d8b7e435bce765e7ac91d51f1b349b87b Mon Sep 17 00:00:00 2001
-From: Fabrice Fontaine <[email protected]>
-Date: Sun, 10 Mar 2024 13:43:12 +0100
-Subject: [PATCH] CMakeLists.txt: add BUILD_WERROR option
-
-Signed-off-by: Fabrice Fontaine <[email protected]>
-Upstream: https://github.com/zhaojh329/libuhttpd/commit/c0f2260d8b7e435bce765e7ac91d51f1b349b87b
----
- CMakeLists.txt | 8 +++++++-
- 1 file changed, 7 insertions(+), 1 deletion(-)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 6fb9651..6719e5f 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -7,7 +7,13 @@ include(CheckLibraryExists)
- list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
- 
- add_definitions(-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64)
--add_compile_options(-O -Wall -Werror --std=gnu99)
-+add_compile_options(-O -Wall --std=gnu99)
-+
-+option(BUILD_WERROR "Build with -Werror" ON)
-+
-+if(BUILD_WERROR)
-+    add_compile_options(-Werror)
-+endif()
- 
- option(BUILD_STATIC "Build static library" OFF)
- 
package/libuhttpd/0004-add-compatibility-with-mbed-tls-3-0-0.patch deleted +0 -64

64 lines not on this page · raw message

package/libuhttpd/libuhttpd.hash +1 -1
index e4fde4eb64..7f0ecc0030 100644
@@ -1,3 +1,3 @@
 # Locally calculated
-sha256  512d4abfced0ec916d985d3d1eac7528e6676eecae6aca27fdaf313374e29f16  libuhttpd-3.14.1.tar.gz
+sha256  ce2abbc599a922c4bac12f1cdf3e9c9740f387f819a54ca01e9fed60905baa40  libuhttpd-3.14.2.tar.gz
 sha256  99efed4bbc0b62f96f999ef23399e38234fb91651af734fd389a52b033a85b55  LICENSE
package/libuhttpd/libuhttpd.mk +1 -1
index 78e0f42b22..dca26fc3c0 100644
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-LIBUHTTPD_VERSION = 3.14.1
+LIBUHTTPD_VERSION = 3.14.2
 LIBUHTTPD_SITE = https://github.com/zhaojh329/libuhttpd/releases/download/v$(LIBUHTTPD_VERSION)
 LIBUHTTPD_LICENSE = MIT
 LIBUHTTPD_LICENSE_FILES = LICENSE
Signature · 6 lines
2.50.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw
In reply to Thomas Perale via buildroot
Quoted 34 lines · Thomas Perale via buildroot

Since the mbedtls bump to v3.6 [1] the libuhttpd fails to build with the following error:

```
[  8%] Building C object src/ssl/CMakeFiles/xssl.dir/mbedtls.c.o
.../buildroot/output/build/libuhttpd-3.14.1/src/ssl/mbedtls.c:52:10: fatal error: mbedtls/certs.h: No such file or directory
   52 | #include <mbedtls/certs.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
```

This error can be reproduced with the following config:

```
cat <<EOF >.config
BR2_arm=y
BR2_cortex_a7=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_MBEDTLS=y
BR2_PACKAGE_LIBUHTTPD=y
EOF
make olddefconfig
make
```

The compatibility with mbedtls v3 has been addressed upstream in the zhaojh329/ssl project included as a submodule of libuhttpd [2].

This patch backport this upstream commit to be applied on the submodule directory. This required adaptation of the line numbers (see [3]) and renaming a function reference passed as parameter of 'mbedtls_pk_parse_keyfile' caused by the commit [4].

Quoted 6 lines

[1] 3481a9643f package/mbedtls: bump to version 3.6.3.1
[2] https://github.com/zhaojh329/ssl/commit/28cc9b5d98179d161673d20e79333ae5a4864228
[3] https://github.com/zhaojh329/ssl/commit/8092b5a490eedeb042cc1036ebeab6442624cf4c#diff-fbc46fa2db83f8649ccf1f46c6a044473b7b228edc7d4c0f7cc04b5a879f6fb7
[4] https://github.com/zhaojh329/ssl/commit/0e7d2f73d769cc4ddb350381cebb5ef6f27ab653#diff-fbc46fa2db83f8649ccf1f46c6a044473b7b228edc7d4c0f7cc04b5a879f6fb7R92

Series applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
In reply to Thomas Perale via buildroot

In reply of:

Quoted 34 lines

Since the mbedtls bump to v3.6 [1] the libuhttpd fails to build with the following error:

```
[  8%] Building C object src/ssl/CMakeFiles/xssl.dir/mbedtls.c.o
.../buildroot/output/build/libuhttpd-3.14.1/src/ssl/mbedtls.c:52:10: fatal error: mbedtls/certs.h: No such file or directory
   52 | #include <mbedtls/certs.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
```

This error can be reproduced with the following config:

```
cat <<EOF >.config
BR2_arm=y
BR2_cortex_a7=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_MBEDTLS=y
BR2_PACKAGE_LIBUHTTPD=y
EOF
make olddefconfig
make
```

The compatibility with mbedtls v3 has been addressed upstream in the zhaojh329/ssl project included as a submodule of libuhttpd [2].

This patch backport this upstream commit to be applied on the submodule directory. This required adaptation of the line numbers (see [3]) and renaming a function reference passed as parameter of 'mbedtls_pk_parse_keyfile' caused by the commit [4].

Quoted 6 lines

[1] 3481a9643f package/mbedtls: bump to version 3.6.3.1
[2] https://github.com/zhaojh329/ssl/commit/28cc9b5d98179d161673d20e79333ae5a4864228
[3] https://github.com/zhaojh329/ssl/commit/8092b5a490eedeb042cc1036ebeab6442624cf4c#diff-fbc46fa2db83f8649ccf1f46c6a044473b7b228edc7d4c0f7cc04b5a879f6fb7
[4] https://github.com/zhaojh329/ssl/commit/0e7d2f73d769cc4ddb350381cebb5ef6f27ab653#diff-fbc46fa2db83f8649ccf1f46c6a044473b7b228edc7d4c0f7cc04b5a879f6fb7R92

Applied to 2025.02.x & 2025.05.x. Thanks

Quoted 82 lines
---
 ...dd-compatibility-with-mbed-tls-3-0-0.patch | 64 +++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 package/libuhttpd/0004-add-compatibility-with-mbed-tls-3-0-0.patch
package/libuhttpd/0004-add-compatibility-with-mbed-tls-3-0-0.patch new file +64 -0
new file mode 100644
index 0000000000..1f45d4634c
@@ -0,0 +1,64 @@
+From 28cc9b5d98179d161673d20e79333ae5a4864228 Mon Sep 17 00:00:00 2001
+From: Jianhui Zhao <[email protected]>
+Date: Sat, 4 May 2024 19:40:07 +0800
+Subject: [PATCH] Add compatibility with Mbed TLS 3.0.0
+
+Signed-off-by: Jianhui Zhao <[email protected]>
+Upstream: https://github.com/zhaojh329/ssl/commit/28cc9b5d98179d161673d20e79333ae5a4864228
+[thomas: 
+  - Apply to submodule directory
+  - Rename 'urandom' to '_urandom'
+  - Adapt line numbers
+]
+Signed-off-by: Thomas Perale <[email protected]>
+---
+ src/ssl/mbedtls.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/src/ssl/mbedtls.c b/src/ssl/mbedtls.c
+index 2e02e1c..cad7e00 100644
+--- a/src/ssl/mbedtls.c
++++ b/src/ssl/mbedtls.c
+@@ -49,7 +49,6 @@
+ #include "ssl.h"
+ 
+ #include <mbedtls/ssl.h>
+-#include <mbedtls/certs.h>
+ #include <mbedtls/x509.h>
+ #include <mbedtls/rsa.h>
+ #include <mbedtls/error.h>
+@@ -136,9 +135,13 @@ static const int default_ciphersuites_client[] =
+     AES_CBC_CIPHERS(ECDHE_ECDSA),
+     AES_CBC_CIPHERS(ECDHE_RSA),
+     AES_CBC_CIPHERS(DHE_RSA),
++#ifdef MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
+     MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,
++#endif
+     AES_CIPHERS(RSA),
++#ifdef MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA
+     MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA,
++#endif
+     0
+ };
+ 
+@@ -221,7 +224,7 @@ static void ssl_update_own_cert(struct ssl_context *ctx)
+     if (!ctx->cert.version)
+         return;
+ 
+-    if (!ctx->key.pk_info)
++    if (mbedtls_pk_get_type(&ctx->key) == MBEDTLS_PK_NONE)
+         return;
+ 
+     mbedtls_ssl_conf_own_cert(&ctx->conf, &ctx->cert, &ctx->key);
+@@ -258,7 +261,11 @@ int ssl_load_key_file(struct ssl_context *ctx, const char *file)
+ {
+     int ret;
+ 
++#if (MBEDTLS_VERSION_NUMBER >= 0x03000000)
++    ret = mbedtls_pk_parse_keyfile(&ctx->key, file, NULL, _urandom, NULL);
++#else
+     ret = mbedtls_pk_parse_keyfile(&ctx->key, file, NULL);
++#endif
+     if (ret)
+         return -1;
+ 
Signature · 6 lines
2.50.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot