Libwebsockets - additional options for jwt support

Hello,

I need to use libwebsockets with the build options -DLWS_WITH_JOSE=1 and -DLWS_WITH_GENCRYPTO=1 to enable JWT support.
This should also be built using the mbedtls and the openssl version.

Should we add a submenu for extra configuration, like this:

diff --git a/libs/libwebsockets/Makefile b/libs/libwebsockets/Makefile
index 2fe7927b2d..aeca66b55a 100644
--- a/libs/libwebsockets/Makefile
+++ b/libs/libwebsockets/Makefile
@@ -25,6 +25,10 @@ PKG_BUILD_DEPENDS:=libubox
 
 CMAKE_INSTALL:=1
 
+PKG_CONFIG_DEPENDS:=\
+   CONFIG_LIBWEBSOCKETS_WITH_JOSE \
+   CONFIG_LIBWEBSOCKETS_WITH_GENCRYPTO
+
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/cmake.mk
 
@@ -33,6 +37,8 @@ CMAKE_OPTIONS += -DISABLE_WERROR=ON
 CMAKE_OPTIONS += -DCMAKE_BUILD_TYPE=Release
 CMAKE_OPTIONS += -DLWS_WITH_EXTERNAL_POLL=ON
 CMAKE_OPTIONS += -DLWS_WITH_ULOOP=ON
+CMAKE_OPTIONS += $(if $(CONFIG_LIBWEBSOCKETS_WITH_JOSE),-DLWS_WITH_JOSE=ON)
+CMAKE_OPTIONS += $(if $(CONFIG_LIBWEBSOCKETS_WITH_GENCRYPTO),-DLWS_WITH_GENCRYPTO=ON)
 
 # turn off all test apps
 CMAKE_OPTIONS += -DLWS_WITHOUT_TESTAPPS=ON
@@ -75,6 +81,23 @@ define Package/libwebsockets-full
    PROVIDES:=libwebsockets libwebsockets-openssl
 endef
 
+define Package/libwebsockets-openssl/config
+menu "libwebsockets Configuration"
+   comment "These options apply to all build variants"
+   config LIBWEBSOCKETS_WITH_JOSE
+       bool "Enable JOSE support (-DLWS_WITH_JOSE=ON)"
+       default n
+       help
+           JOSE JSON Web Signature / Encryption / Keys (RFC7515/6/) API
+
+   config LIBWEBSOCKETS_WITH_GENCRYPTO
+       bool "Enable Generic Crypto (-DLWS_WITH_GENCRYPTO=ON)"
+       default n
+       help
+           Enable support for Generic Crypto apis independent of TLS backend
+endmenu
+endef
+
 ifeq ($(BUILD_VARIANT),openssl)
     CMAKE_OPTIONS += -DLWS_OPENSSL_CLIENT_CERTS=/etc/ssl/certs
     CMAKE_OPTIONS += -DLWS_WITH_SSL=ON

Thanks in advance.

1 Like