Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1746072174, "reponame":"libwebsockets", "desc":"libwebsockets lightweight C networking library", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets", "f":3, "items": [ {"schema":"libjg2-1", "cid":"62997d554ce8052c4c65cfb75f3c65d7", "commit": {"type":"commit", "time": 1459259358, "time_ofs": 480, "oid_tree": { "oid": "60c5b6aab7bfabd0d0f0a1cfb75e0b93a0a33448", "alias": []}, "oid":{ "oid": "1a3f17700e483ea5354bda3f35d513fa30734d47", "alias": []}, "msg": "mbedtls and polarssl first part", "sig_commit": { "git_time": { "time": 1459259358, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }, "sig_author": { "git_time": { "time": 1459166282, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }}, "body": "mbedtls and polarssl first part\n\npolarssl is the old name for mbedtls. Unfortunately the two are confused in eg,\nFedora. For our purposes, polarssl or mbedtls \u003c 2.0 has includes in\n/usr/include/polarssl and polarssl_ apis and we call that \u0022polarssl\u0022.\n\npolarssl or mbedtls \u003e\u003d2.0 has includes in /usr/include/mbedtls and mbedtls_ apis,\nwe call that \u0022mbedtls\u0022.\n\nThis has to be spelled out clearly because eg Fedora has a package \u0022mbedtls\u0022 which\nis 1.3.x and has the polarssl_ apis and include path. We will deal with that as\n\u0022polarssl\u0022 despite the package name then.\n\nThis patch lets you use LWS_USE_POLARSSL or LWS_USE_MBEDTLS and set the include and\nlibrary path like this\n\ncmake .. -DLWS_USE_POLARSSL\u003d1 -DLWS_POLARSSL_INCLUDE_DIRS\u003d/usr/include -DLWS_POLARSSL_LIBRARIES\u003d/usr/lib64/libmbedtls.so.9\n\nThis patch adds the cmake support and adapts [private-]libwebsockets.h but doesn't\nmodify the apis in ssl[-*].c yet.\n\nSigned-off-by: Andy Green \u003candy@warmcat.com\u003e" , "diff": "diff --git a/CMakeLists.txt b/CMakeLists.txt\nindex c8cf300..e93d14d 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -63,6 +63,8 @@ option(LWS_WITH_SHARED \u0022Build the shared version of the library\u0022 ON)\n option(LWS_WITH_SSL \u0022Include SSL support (default OpenSSL, wolfSSL if LWS_USE_WOLFSSL is set)\u0022 ON)\n option(LWS_USE_CYASSL \u0022Use CyaSSL replacement for OpenSSL. When setting this, you also need to specify LWS_CYASSL_LIBRARIES and LWS_CYASSL_INCLUDE_DIRS\u0022 OFF)\n option(LWS_USE_WOLFSSL \u0022Use wolfSSL replacement for OpenSSL. When setting this, you also need to specify LWS_WOLFSSL_LIBRARIES and LWS_WOLFSSL_INCLUDE_DIRS\u0022 OFF)\n+option(LWS_USE_POLARSSL \u0022Use Polarssl (or mbedtls \u003c 2.0) replacement for OpenSSL. When setting this, you also need to specify LWS_POLARSSL_LIBRARIES and LWS_POLARSSL_INCLUDE_DIRS\u0022 OFF)\n+option(LWS_USE_MBEDTLS \u0022Use mbedTLS (\u003e\u003d2.0) replacement for OpenSSL. When setting this, you also need to specify LWS_MBEDTLS_LIBRARIES and LWS_MBEDTLS_INCLUDE_DIRS\u0022 OFF)\n option(LWS_WITH_ZLIB \u0022Include zlib support (required for extensions)\u0022 ON)\n option(LWS_WITH_LIBEV \u0022Compile with support for libev\u0022 OFF)\n option(LWS_WITH_LIBUV \u0022Compile with support for libuv\u0022 OFF)\n@@ -156,16 +158,18 @@ set(LWS_OPENSSL_LIBRARIES CACHE PATH \u0022Path to the OpenSSL library\u0022)\n set(LWS_OPENSSL_INCLUDE_DIRS CACHE PATH \u0022Path to the OpenSSL include directory\u0022)\n set(LWS_WOLFSSL_LIBRARIES CACHE PATH \u0022Path to the wolfSSL library\u0022)\n set(LWS_WOLFSSL_INCLUDE_DIRS CACHE PATH \u0022Path to the wolfSSL include directory\u0022)\n-set(LWS_LIBEV_LIBRARIES CACHE PATH \u0022Path to the libev library\u0022)\n+set(LWS_POLARSSL_LIBRARIES CACHE PATH \u0022Path to the PolarSSL library\u0022)\n+set(LWS_POLARSSL_INCLUDE_DIRS CACHE PATH \u0022Path to the PolarSSL include directory\u0022)\n+set( CACHE PATH \u0022Path to the libev library\u0022)\n set(LWS_LIBEV_INCLUDE_DIRS CACHE PATH \u0022Path to the libev include directory\u0022)\n set(LWS_LIBUV_LIBRARIES CACHE PATH \u0022Path to the libuv library\u0022)\n-set(LWS_LIBUV_INCLUDE_DIRS CACHE PATH \u0022Path to the libuv include directory\u0022)\n+set(LWS_LIBUVLWS_LIBEV_LIBRARIES_INCLUDE_DIRS CACHE PATH \u0022Path to the libuv include directory\u0022)\n \n if (NOT LWS_WITH_SSL)\n \tset(LWS_WITHOUT_BUILTIN_SHA1 OFF)\n endif()\n \n-if (LWS_WITH_SSL AND NOT LWS_USE_WOLFSSL)\n+if (LWS_WITH_SSL AND NOT LWS_USE_WOLFSSL AND NOT LWS_USE_POLARSSL AND NOT LWS_USE_MBEDTLS)\n \tif (\u0022${LWS_OPENSSL_LIBRARIES}\u0022 STREQUAL \u0022\u0022 OR \u0022${LWS_OPENSSL_INCLUDE_DIRS}\u0022 STREQUAL \u0022\u0022)\n \telse()\n \t\tset(OPENSSL_LIBRARIES ${LWS_OPENSSL_LIBRARIES})\n@@ -194,6 +198,32 @@ if (LWS_WITH_SSL AND LWS_USE_WOLFSSL)\n \tendif()\n endif()\n \n+if (LWS_WITH_SSL AND LWS_USE_POLARSSL)\n+\tif (\u0022${LWS_POLARSSL_LIBRARIES}\u0022 STREQUAL \u0022\u0022 OR \u0022${LWS_POLARSSL_INCLUDE_DIRS}\u0022 STREQUAL \u0022\u0022)\n+\t\tif (NOT POLARSSL_FOUND)\n+\t\t\tmessage(FATAL_ERROR \u0022You must set LWS_POLARSSL_LIBRARIES and LWS_POLARSSL_INCLUDE_DIRS when LWS_USE_POLARSSL is turned on.\u0022)\n+\t\tendif()\n+\telse()\n+\t\tset(POLARSSL_LIBRARIES ${LWS_POLARSSL_LIBRARIES})\n+\t\tset(POLARSSL_INCLUDE_DIRS ${LWS_POLARSSL_INCLUDE_DIRS})\n+\t\tset(POLARSSL_FOUND 1)\n+\tendif()\n+\tset(USE_POLARSSL 1)\n+endif()\n+\n+if (LWS_WITH_SSL AND LWS_USE_MBEDTLS)\n+\tif (\u0022${LWS_MBEDTLS_LIBRARIES}\u0022 STREQUAL \u0022\u0022 OR \u0022${LWS_MBEDTLS_INCLUDE_DIRS}\u0022 STREQUAL \u0022\u0022)\n+\t\tif (NOT MBEDTLS_FOUND)\n+\t\t\tmessage(FATAL_ERROR \u0022You must set LWS_MBEDTLS_LIBRARIES and LWS_MBEDTLS_INCLUDE_DIRS when LWS_USE_MBEDTLS is turned on.\u0022)\n+\t\tendif()\n+\telse()\n+\t\tset(MBEDTLS_LIBRARIES ${LWS_MBEDTLS_LIBRARIES})\n+\t\tset(MBEDTLS_INCLUDE_DIRS ${LWS_MBEDTLS_INCLUDE_DIRS})\n+\t\tset(MBEDTLS_FOUND 1)\n+\tendif()\n+\tset(USE_MBEDTLS 1)\n+endif()\n+\n if (LWS_WITH_ZLIB AND NOT LWS_USE_BUNDLED_ZLIB)\n \tif (\u0022${LWS_ZLIB_LIBRARIES}\u0022 STREQUAL \u0022\u0022 OR \u0022${LWS_ZLIB_INCLUDE_DIRS}\u0022 STREQUAL \u0022\u0022)\n \telse()\n@@ -688,7 +718,7 @@ endif()\n #\n if (LWS_WITH_SSL)\n \tmessage(\u0022Compiling with SSL support\u0022)\n-\n+\tset(chose_ssl 0)\n \tif (LWS_USE_WOLFSSL)\n \t\t# Use wolfSSL as OpenSSL replacement.\n \t\t# TODO: Add a find_package command for this also.\n@@ -710,7 +740,34 @@ if (LWS_WITH_SSL)\n \t\tendif()\n \n \t\tlist(APPEND LIB_LIST \u0022${WOLFSSL_LIBRARIES}\u0022)\n-\telse()\n+\t\tset(chose_ssl 1)\n+\tendif()\n+\n+\tif (LWS_USE_POLARSSL)\n+\t\tmessage(\u0022POLARSSL include dir: ${POLARSSL_INCLUDE_DIRS}\u0022)\n+\t\tmessage(\u0022POLARSSL libraries: ${POLARSSL_LIBRARIES}\u0022)\n+\n+\t\tforeach(inc ${POLARSSL_INCLUDE_DIRS})\n+\t\t\tinclude_directories(\u0022${inc}\u0022 \u0022${inc}/polarssl\u0022)\n+\t\tendforeach()\n+\n+\t\tlist(APPEND LIB_LIST \u0022${POLARSSL_LIBRARIES}\u0022)\n+\t\tset(chose_ssl 1)\n+\tendif()\n+\t\n+\tif (LWS_USE_MBEDTLS)\n+\t\tmessage(\u0022MBEDTLS include dir: ${MBEDTLS_INCLUDE_DIRS}\u0022)\n+\t\tmessage(\u0022MBEDTLS libraries: ${MBEDTLS_LIBRARIES}\u0022)\n+\n+\t\tforeach(inc ${MBEDTLS_INCLUDE_DIRS})\n+\t\t\tinclude_directories(\u0022${inc}\u0022 \u0022${inc}/mbedtls\u0022)\n+\t\tendforeach()\n+\n+\t\tlist(APPEND LIB_LIST \u0022${MBEDTLS_LIBRARIES}\u0022)\n+\t\tset(chose_ssl 1)\n+\tendif()\n+\n+\tif (NOT chose_ssl)\n \t\tif (NOT OPENSSL_FOUND)\n \t\t\t# TODO: Add support for STATIC also.\n \t\t\tfind_package(OpenSSL REQUIRED)\n@@ -863,12 +920,13 @@ if (NOT LWS_WITHOUT_TESTAPPS)\n \t\tlist(APPEND TEST_APP_LIST ${TEST_NAME})\n \tendmacro()\n \n-\tif (LWS_WITH_SSL AND NOT LWS_USE_WOLFSSL)\n+\tif (LWS_WITH_SSL AND NOT LWS_USE_WOLFSSL AND NOT LWS_USE_POLARSSL AND NOT LWS_USE_MBEDTLS)\n \t\tmessage(\u0022Searching for OpenSSL executable and dlls\u0022)\n \t\tfind_package(OpenSSLbins)\n \t\tmessage(\u0022OpenSSL executable: ${OPENSSL_EXECUTABLE}\u0022)\n \tendif()\n \n+\n \tif (NOT LWS_WITHOUT_SERVER)\n \t\t#\n \t\t# test-server\n@@ -1293,6 +1351,8 @@ if (LWS_USE_WOLFSSL)\n \tmessage(\u0022 LWS_WOLFSSL_LIBRARIES \u003d ${LWS_WOLFSSL_LIBRARIES}\u0022)\n \tmessage(\u0022 LWS_WOLFSSL_INCLUDE_DIRS \u003d ${LWS_WOLFSSL_INCLUDE_DIRS}\u0022)\n endif()\n+message(\u0022 LWS_USE_POLARSSL \u003d ${LWS_USE_POLARSSL} (PolarSSL replacement for OpenSSL)\u0022)\n+message(\u0022 LWS_USE_MBEDTLS \u003d ${LWS_USE_MBEDTLS} (mbedtls (nee Polarssl) replacement for OpenSSL)\u0022)\n message(\u0022 LWS_WITHOUT_BUILTIN_SHA1 \u003d ${LWS_WITHOUT_BUILTIN_SHA1}\u0022)\n message(\u0022 LWS_WITHOUT_BUILTIN_GETIFADDRS \u003d ${LWS_WITHOUT_BUILTIN_GETIFADDRS}\u0022)\n message(\u0022 LWS_WITHOUT_CLIENT \u003d ${LWS_WITHOUT_CLIENT}\u0022)\ndiff --git a/lib/libwebsockets.h b/lib/libwebsockets.h\nindex 939843e..9479fce 100644\n--- a/lib/libwebsockets.h\n+++ b/lib/libwebsockets.h\n@@ -201,17 +201,31 @@ struct sockaddr_in;\n #endif\n \n #ifdef LWS_OPENSSL_SUPPORT\n+\n #ifdef USE_WOLFSSL\n #ifdef USE_OLD_CYASSL\n #include \u003ccyassl/openssl/ssl.h\u003e\n+#include \u003ccyassl/error-ssl.h\u003e\n #else\n #include \u003cwolfssl/openssl/ssl.h\u003e\n+#include \u003cwolfssl/error-ssl.h\u003e\n #endif /* not USE_OLD_CYASSL */\n #else\n+#if defined(LWS_USE_POLARSSL)\n+#include \u003cpolarssl/ssl.h\u003e\n+#define SSL_CTX ssl_context\n+#define SSL ssl_session\n+#else\n+#if defined(LWS_USE_MBEDTLS)\n+#include \u003cmbedtls/ssl.h\u003e\n+#else\n #include \u003copenssl/ssl.h\u003e\n+#endif /* not USE_MBEDTLS */\n+#endif /* not USE_POLARSSL */\n #endif /* not USE_WOLFSSL */\n #endif\n \n+\n #define CONTEXT_PORT_NO_LISTEN -1\n \n enum lws_log_levels {\ndiff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h\nindex 54994b0..498aec5 100644\n--- a/lib/private-libwebsockets.h\n+++ b/lib/private-libwebsockets.h\n@@ -184,6 +184,7 @@ static inline int compatible_close(int fd) { return close(fd); }\n #endif\n \n #ifdef LWS_OPENSSL_SUPPORT\n+\n #ifdef USE_WOLFSSL\n #ifdef USE_OLD_CYASSL\n #include \u003ccyassl/openssl/ssl.h\u003e\n@@ -193,11 +194,30 @@ static inline int compatible_close(int fd) { return close(fd); }\n #include \u003cwolfssl/error-ssl.h\u003e\n #endif /* not USE_OLD_CYASSL */\n #else\n+#if defined(LWS_USE_POLARSSL)\n+#include \u003cpolarssl/ssl.h\u003e\n+#include \u003cpolarssl/error.h\u003e\n+#include \u003cpolarssl/md5.h\u003e\n+#include \u003cpolarssl/sha1.h\u003e\n+#include \u003cpolarssl/ecdh.h\u003e\n+#else\n+#if defined(LWS_USE_MBEDTLS)\n+#include \u003cmbedtls/ssl.h\u003e\n+#include \u003cmbedtls/error.h\u003e\n+#include \u003cmbedtls/md5.h\u003e\n+#include \u003cmbedtls/sha1.h\u003e\n+#include \u003cmbedtls/ecdh.h\u003e\n+#else\n #include \u003copenssl/ssl.h\u003e\n #include \u003copenssl/evp.h\u003e\n #include \u003copenssl/err.h\u003e\n #include \u003copenssl/md5.h\u003e\n #include \u003copenssl/sha.h\u003e\n+#ifdef LWS_HAVE_OPENSSL_ECDH_H\n+#include \u003copenssl/ecdh.h\u003e\n+#endif\n+#endif /* not USE_MBEDTLS */\n+#endif /* not USE_POLARSSL */\n #endif /* not USE_WOLFSSL */\n #endif\n \n@@ -1160,7 +1180,9 @@ struct lws {\n #endif\n #ifdef LWS_OPENSSL_SUPPORT\n \tSSL *ssl;\n+#if !defined(LWS_USE_POLARSSL) \u0026\u0026 !defined(LWS_USE_MBEDTLS)\n \tBIO *client_bio;\n+#endif\n \tstruct lws *pending_read_list_prev, *pending_read_list_next;\n #endif\n #ifdef LWS_WITH_HTTP_PROXY\ndiff --git a/lib/ssl-client.c b/lib/ssl-client.c\nindex 762398c..4ae10a6 100644\n--- a/lib/ssl-client.c\n+++ b/lib/ssl-client.c\n@@ -20,13 +20,6 @@\n */\n \n #include \u0022private-libwebsockets.h\u0022\n-#ifndef USE_WOLFSSL\n- #include \u003copenssl/err.h\u003e\n-#endif\n-\n-#ifdef LWS_HAVE_OPENSSL_ECDH_H\n-#include \u003copenssl/ecdh.h\u003e\n-#endif\n \n extern int openssl_websocket_private_data_index,\n openssl_SSL_CTX_private_data_index;\ndiff --git a/lib/ssl-server.c b/lib/ssl-server.c\nindex 3104d83..7227f2b 100644\n--- a/lib/ssl-server.c\n+++ b/lib/ssl-server.c\n@@ -20,13 +20,6 @@\n */\n \n #include \u0022private-libwebsockets.h\u0022\n-#ifndef USE_WOLFSSL\n- #include \u003copenssl/err.h\u003e\n-#endif\n-\n-#ifdef LWS_HAVE_OPENSSL_ECDH_H\n-#include \u003copenssl/ecdh.h\u003e\n-#endif\n \n extern int openssl_websocket_private_data_index,\n openssl_SSL_CTX_private_data_index;\ndiff --git a/lib/ssl.c b/lib/ssl.c\nindex b3031dd..1bb8e0c 100644\n--- a/lib/ssl.c\n+++ b/lib/ssl.c\n@@ -20,13 +20,6 @@\n */\n \n #include \u0022private-libwebsockets.h\u0022\n-#ifndef USE_WOLFSSL\n- #include \u003copenssl/err.h\u003e\n-#endif\n-\n-#ifdef LWS_HAVE_OPENSSL_ECDH_H\n-#include \u003copenssl/ecdh.h\u003e\n-#endif\n \n int openssl_websocket_private_data_index,\n openssl_SSL_CTX_private_data_index;\ndiff --git a/lws_config.h.in b/lws_config.h.in\nindex 341515f..f90abeb 100644\n--- a/lws_config.h.in\n+++ b/lws_config.h.in\n@@ -14,6 +14,9 @@\n (older) CyaSSL library */\n #cmakedefine USE_OLD_CYASSL\n \n+#cmakedefine LWS_USE_MBEDTLS\n+#cmakedefine LWS_USE_POLARSSL\n+\n /* The Libwebsocket version */\n #cmakedefine LWS_LIBRARY_VERSION \u0022${LWS_LIBRARY_VERSION}\u0022\n \n","s":{"c":1746072174,"u": 11963}} ],"g": 14452,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}