Skip to content

Commit

Permalink
Libwebsockets: temp fix for mbedtls 3.6+
Browse files Browse the repository at this point in the history
3.6 removed mbedtls_x509_get_cert into private header, redefined it in resonable place to temperatly fix it, and make it not depend on mbedtls_version_C. everything is upstreamed so won't need when upstrea release 4.3.4

Signed-off-by: Seo Suchan <tjtncks@gmail.com>
  • Loading branch information
orangepizza committed May 10, 2024
1 parent 7157d5a commit 8eb0d2d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/libwebsockets/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ endef
define Package/libwebsockets-mbedtls
$(call Package/$(PKG_NAME)/Default)
TITLE += (mbedTLS)
DEPENDS += +libmbedtls @MBEDTLS_VERSION_C
DEPENDS += +libmbedtls
VARIANT:=mbedtls
PROVIDES:=libwebsockets
CONFLICTS:=libwebsockets-openssl
Expand Down
28 changes: 28 additions & 0 deletions libs/libwebsockets/patches/110-mbedtls36_compilefix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 017dfcb144c557bb4bc72669168ad7b70a34ce57 Mon Sep 17 00:00:00 2001
From: Seo Suchan <tjtncks@gmail.com>
Date: Fri, 3 May 2024 17:18:46 +0900
Subject: [PATCH 1/2] mbedtls: fix compile on mbedtls 3.6+ they moved
mbedtls_x509_get_name into interal zone, this declares it again in a file I
looked approperate to hold one

Signed-off-by: Seo Suchan <tjtncks@gmail.com>
---
lib/tls/mbedtls/private-lib-tls-mbedtls.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/lib/tls/mbedtls/private-lib-tls-mbedtls.h b/lib/tls/mbedtls/private-lib-tls-mbedtls.h
index 162d9726..73f49c01 100644
--- a/lib/tls/mbedtls/private-lib-tls-mbedtls.h
+++ b/lib/tls/mbedtls/private-lib-tls-mbedtls.h
@@ -57,3 +57,8 @@ lws_tls_mbedtls_cert_info(mbedtls_x509_crt *x509, enum lws_tls_cert_info type,
int
lws_x509_get_crt_ext(mbedtls_x509_crt *crt, mbedtls_x509_buf *skid,
lws_mbedtls_x509_authority *akid);
+
+/* redefine hidden mbedtls internal functions*/
+int
+mbedtls_x509_get_name(unsigned char **p, const unsigned char *end,
+ mbedtls_x509_name *cur);
--
2.39.2

42 changes: 42 additions & 0 deletions libs/libwebsockets/patches/120-removed-mbedtlsverc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
From adcc5a1ccb9f6ffe9fca793ea67e6c3e7ad8274a Mon Sep 17 00:00:00 2001
From: Seo Suchan <tjtncks@gmail.com>
Date: Tue, 7 May 2024 12:46:08 +0900
Subject: [PATCH 2/2] mbedtls: make it no longer depend on mbedtls_version_c
complie flag

everything that code does is already done as macro constants
and openwrt doesn't build with mbedtls with that flag by default

Signed-off-by: Seo Suchan <tjtncks@gmail.com>
---
lib/core/context.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/core/context.c b/lib/core/context.c
index b9b724ed..dc1a09a0 100644
--- a/lib/core/context.c
+++ b/lib/core/context.c
@@ -788,11 +788,16 @@ lws_create_context(const struct lws_context_creation_info *info)
#endif /* network */

#if defined(LWS_WITH_MBEDTLS)
- mbedtls_version_get_string(mbedtls_version);
-#endif
+ {
+ char mbedtls_version[32];

-#if defined(LWS_WITH_MBEDTLS)
- lwsl_cx_notice(context, "LWS: %s, MbedTLS-%s %s%s", library_version, mbedtls_version, opts_str, s);
+#if defined(MBEDTLS_VERSION_C)
+ mbedtls_version_get_string(mbedtls_version);
+#else
+ lws_snprintf(mbedtls_version, sizeof(mbedtls_version), "%s", MBEDTLS_VERSION_STRING);
+#endif
+ lwsl_cx_notice(context, "LWS: %s, MbedTLS-%s %s%s", library_version, mbedtls_version, opts_str, s);
+ }
#else
lwsl_cx_notice(context, "LWS: %s, %s%s", library_version, opts_str, s);
#endif
--
2.39.2

0 comments on commit 8eb0d2d

Please sign in to comment.