Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation issue with libwebsocket with openssl version OpenSSL v3.3.1 #3209

Open
sush126 opened this issue Aug 22, 2024 · 10 comments
Open

Comments

@sush126
Copy link

sush126 commented Aug 22, 2024

Hi @lws-team , On the Windows platform, I am getting the following error. Could you please let me know if there is support for OpenSSL version 3.3.1?

Error :

9>D:\libweb4.3.2\libwebsockets\lib\tls\openssl\openssl-server.c(436,9): error C2220: the following warning is treated as an error
9>D:\libweb4.3.2\libwebsockets\lib\tls\openssl\openssl-server.c(436,9): warning C4996: 'EC_KEY_new_by_curve_name': Since OpenSSL 3.0
9>D:\libweb4.3.2\libwebsockets\lib\tls\openssl\openssl-server.c(442,2): warning C4996: 'EC_KEY_free': Since OpenSSL 3.0
9>D:\libweb4.3.2\libwebsockets\lib\tls\openssl\openssl-server.c(485,11): warning C4996: 'EVP_PKEY_get1_EC_KEY': Since OpenSSL 3.0
9>D:\libweb4.3.2\libwebsockets\lib\tls\openssl\openssl-server.c(493,2): warning C4996: 'EC_KEY_free': Since OpenSSL 3.0

@lws-team
Copy link
Member

Should be enough to use -DDISABLE_WERROR=1 at cmake

@sush126
Copy link
Author

sush126 commented Aug 22, 2024

i have tryied but same issue , please find cmakecache for reference.
i am using below command to build lws :
cmake -G "NMake Makefiles" -DLWS_WITHOUT_EXTENSIONS=OFF -DLWS_SSL_SERVER_WITH_ECDH_CERT=1
-DDISABLE_WERROR=1 -DCMAKE_BUILD_TYPE=RELEASE -DOPENSSL_ROOT_DIR="C:\\Program Files\\OpenSSL-Win64" -DCMAKE_INSTALL_PREFIX="C:\\Program Files\\libwebsockets" ..
image

@lws-team
Copy link
Member

Dunno... if you are using some GUI or whatever for msvc, you can try turning it off in there. Otherwise you'll have to look at the toolchain commandline (ie, compiler) and see what is really set there and debug from there.

@SanjayPatait
Copy link

Same with my machine as well, when tried to build lws 4.3.2 with openssl 3.0.15

D:\libwebsockets\build64>nmake

Microsoft (R) Program Maintenance Utility Version 14.41.34120.0
Copyright (C) Microsoft Corporation.  All rights reserved.

[  0%] Built target GENHDR
[  1%] Building C object lib/CMakeFiles/websockets.dir/tls/openssl/openssl-server.c.obj
openssl-server.c
D:\libwebsockets\lib\tls\openssl\openssl-server.c(436): error C2220: the following warning is treated as an error
D:\libwebsockets\lib\tls\openssl\openssl-server.c(436): warning C4996: 'EC_KEY_new_by_curve_name': Since OpenSSL 3.0
D:\libwebsockets\lib\tls\openssl\openssl-server.c(442): warning C4996: 'EC_KEY_free': Since OpenSSL 3.0
D:\libwebsockets\lib\tls\openssl\openssl-server.c(485): warning C4996: 'EVP_PKEY_get1_EC_KEY': Since OpenSSL 3.0
D:\libwebsockets\lib\tls\openssl\openssl-server.c(493): warning C4996: 'EC_KEY_free': Since OpenSSL 3.0
NMAKE : fatal error U1077: 'C:\Strawberry\c\bin\cmake.exe -E cmake_cl_compile_depends --dep-file=CMakeFiles\websockets.dir\tls\openssl\openssl-server.c.obj.d --working-dir=D:\libwebsockets\build64\lib --filter-prefix="Note: including file: " -- C:\PROGRA~1\MICROS~3\2022\PROFES~1\VC\Tools\MSVC\1441~1.341\bin\Hostx64\x64\cl.exe @C:\Users\z002uefr\AppData\Local\Temp\nmC0BD.tmp' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\nmake.exe" -s -f lib\CMakeFiles\websockets.dir\build.make /nologo -SL                 lib\CMakeFiles\websockets.dir\build' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.41.34120\bin\HostX64\x64\nmake.exe" -s -f CMakeFiles\Makefile2 /nologo -S                  all' : return code '0x2'
Stop.

Any successful solution will be appreciated...Thanks in advance.

@SanjayPatait
Copy link

For now I am able to build it by disabling warning using Pragma:

  • Add below line in 'openssl-server.c' file before line 436 to disable the warning
    • #pragma warning(disable:4996)
  • Add below line after line 493 to enable warning
    • #pragma warning(default:4996)

@yu-cheng-kuo-28
Copy link

I got a similar issue on Linux platform and failed to resolve it by adding either -DDISABLE_WERROR=1 (issue #3209, this one), -DLWS_SUPPRESS_DEPRECATED_API_WARNINGS=1 (issue #2200 & #3020), or -DLWS_WITH_BUNDLED_ZLIB=OFF (issue #3020) in libwebsockets.mk under Buildroot. In addition, modifying 'openssl-server.c' doesn't sound like a proper solution to me.

Thanks in advance!

[  1%] Building C object CMakeFiles/websockets.dir/lib/tls/openssl/openssl-server.c.o
[  2%] Building C object CMakeFiles/websockets_shared.dir/lib/tls/openssl/openssl-server.c.o
/buildroot/output/build/libwebsockets-4.0.21/lib/tls/openssl/openssl-server.c: In function ‘lws_tls_server_certs_load’:
buildroot/output/build/libwebsockets-4.0.21/lib/tls/openssl/openssl-server.c:403:2: error: ‘EC_KEY_new_by_curve_name’ is deprecated (declared at /buildroot/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/openssl/ec.h:998): Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  ecdh = EC_KEY_new_by_curve_name(ecdh_nid);
  ^
buildroot/output/build/libwebsockets-4.0.21/lib/tls/openssl/openssl-server.c:409:2: error: ‘EC_KEY_free’ is deprecated (declared at /buildroot/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/openssl/ec.h:1003): Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  EC_KEY_free(ecdh);
  ^
buildroot/output/build/libwebsockets-4.0.21/lib/tls/openssl/openssl-server.c:451:2: error: ‘EVP_PKEY_get1_EC_KEY’ is deprecated (declared at /buildroot/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/openssl/evp.h:1376): Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  EC_key = EVP_PKEY_get1_EC_KEY(pkey);
  ^
buildroot/output/build/libwebsockets-4.0.21/lib/tls/openssl/openssl-server.c:459:2: error: ‘EC_KEY_free’ is deprecated (declared at /buildroot/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/openssl/ec.h:1003): Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  EC_KEY_free(EC_key);
  ^
buildroot/output/build/libwebsockets-4.0.21/lib/tls/openssl/openssl-server.c: In function ‘lws_tls_server_certs_load’:
buildroot/output/build/libwebsockets-4.0.21/lib/tls/openssl/openssl-server.c:403:2: error: ‘EC_KEY_new_by_curve_name’ is deprecated (declared at /buildroot/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/openssl/ec.h:998): Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  ecdh = EC_KEY_new_by_curve_name(ecdh_nid);
  ^
buildroot/output/build/libwebsockets-4.0.21/lib/tls/openssl/openssl-server.c:409:2: error: ‘EC_KEY_free’ is deprecated (declared at /buildroot/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/openssl/ec.h:1003): Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  EC_KEY_free(ecdh);
  ^
buildroot/output/build/libwebsockets-4.0.21/lib/tls/openssl/openssl-server.c:451:2: error: ‘EVP_PKEY_get1_EC_KEY’ is deprecated (declared at /buildroot/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/openssl/evp.h:1376): Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  EC_key = EVP_PKEY_get1_EC_KEY(pkey);
  ^
buildroot/output/build/libwebsockets-4.0.21/lib/tls/openssl/openssl-server.c:459:2: error: ‘EC_KEY_free’ is deprecated (declared at /buildroot/output/host/arm-buildroot-linux-gnueabi/sysroot/usr/include/openssl/ec.h:1003): Since OpenSSL 3.0 [-Werror=deprecated-declarations]
  EC_KEY_free(EC_key);
  ^
cc1: all warnings being treated as errors
cc1: all warnings being treated as errors
CMakeFiles/websockets.dir/build.make:761: recipe for target 'CMakeFiles/websockets.dir/lib/tls/openssl/openssl-server.c.o' failed
make[6]: *** [CMakeFiles/websockets.dir/lib/tls/openssl/openssl-server.c.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'CMakeFiles/websockets.dir/all' failed
make[5]: *** [CMakeFiles/websockets.dir/all] Error 2
make[5]: *** Waiting for unfinished jobs....
CMakeFiles/websockets_shared.dir/build.make:761: recipe for target 'CMakeFiles/websockets_shared.dir/lib/tls/openssl/openssl-server.c.o' failed
make[6]: *** [CMakeFiles/websockets_shared.dir/lib/tls/openssl/openssl-server.c.o] Error 1
CMakeFiles/Makefile2:111: recipe for target 'CMakeFiles/websockets_shared.dir/all' failed
make[5]: *** [CMakeFiles/websockets_shared.dir/all] Error 2
Makefile:155: recipe for target 'all' failed
make[4]: *** [all] Error 2
package/pkg-generic.mk:247: recipe for target '/buildroot/output/build/libwebsockets-4.0.21/.stamp_built' failed
make[3]: *** [/buildroot/output/build/libwebsockets-4.0.21/.stamp_built] Error 2
Makefile:103: recipe for target 'all' failed
make[2]: *** [all] Error 2
Makefile:206: recipe for target 'build' failed
make[1]: *** [build] Error 2
Makefile:421: recipe for target 'buildroot' failed
make: *** [buildroot] Error 2

@lws-team
Copy link
Member

lws-team commented Oct 8, 2024

Shouldn't OPENSSL_VERSION_NUMBER help with this already? What does yours say? Rocky's OpenSSL has it in /usr/include/openssl/opensslv.h as v3.0.7 or 0x30000070.

@yu-cheng-kuo-28
Copy link

yu-cheng-kuo-28 commented Oct 8, 2024

I have OpenSSL v3.0.12 with libwebsockets v4.0.12 (though not entirely sure about the latter one; I’ll check on the office PC tomorrow). Thank you for the prompt reply!

EDIT: Checked afterward and found that it's actually libopenssl v3.0.14 + libwebsockets v4.0.21

@lws-team
Copy link
Member

lws-team commented Oct 8, 2024

Nobody is looking after that old lws. You should use either v4.3-stable (which is still getting fix patches) or main.

In main and probably v4.3-stable, the logic to build this code will avoid it if the version >3.x.x which should be enough to avoid problems.

@yu-cheng-kuo-28
Copy link

Solved the issue by merely upgrading libwebsockets from v4.0.21 to v4.3.2 without adding any flag in LIBWEBSOCKETS_CONF_OPTS! Thank you Andy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants