allinurl / gwsocket

fast, standalone, language-agnostic WebSocket server RFC6455 compliant
http://gwsocket.io
MIT License
745 stars 67 forks source link

make fails on Ubuntu 20. #36

Closed imatasic closed 3 years ago

imatasic commented 3 years ago

When configured with --enable-ssl make spews the following errors:

src/websocket.c: In function ‘shutdown_ssl’:
src/log.h:48:24: warning: this statement may fall through [-Wimplicit-fallthrough=]
   48 | #define LOG(x) do { if (DEBUG_TEST) dbg_printf x; } while (0)
      |                        ^
src/websocket.c:730:5: note: in expansion of macro ‘LOG’
  730 |     LOG (("SSL: SSL_shutdown, probably unrecoverable, forcing close.\n"));
      |     ^~~
src/websocket.c:731:3: note: here
  731 |   case SSL_ERROR_ZERO_RETURN:
      |   ^~~~
src/websocket.c: In function ‘send_ssl_buffer’:
src/websocket.c:862:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
  862 |     if ((bytes < 0 && (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)))
      |        ^
src/websocket.c:865:3: note: here
  865 |   case SSL_ERROR_ZERO_RETURN:
      |   ^~~~
src/websocket.c: In function ‘accept_ssl’:
src/websocket.c:766:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
  766 |     if (ret < 0 && (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)) {
      |        ^
src/websocket.c:772:3: note: here
  772 |   case SSL_ERROR_ZERO_RETURN:
      |   ^~~~
src/websocket.c: In function ‘read_ssl_socket’:
src/websocket.c:903:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
  903 |       if ((bytes < 0 && (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)))
      |          ^
src/websocket.c:905:5: note: here
  905 |     case SSL_ERROR_ZERO_RETURN:
      |     ^~~~
depbase=`echo src/xmalloc.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -DHAVE_CONFIG_H -I. -I./src    -O2 -Wno-long-long -Wall -W -Wnested-externs -Wformat=2 -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare -Wredundant-decls -Wbad-function-cast -Winline -Wcast-align -Wextra -Wdeclaration-after-statement -Wno-missing-field-initializers  -MT src/xmalloc.o -MD -MP -MF $depbase.Tpo -c -o src/xmalloc.o src/xmalloc.c &&\
mv -f $depbase.Tpo $depbase.Po
gcc -O2 -Wno-long-long -Wall -W -Wnested-externs -Wformat=2 -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare -Wredundant-decls -Wbad-function-cast -Winline -Wcast-align -Wextra -Wdeclaration-after-statement -Wno-missing-field-initializers  -rdynamic -rdynamic  -o gwsocket src/base64.o src/gslist.o src/gwsocket.o src/log.o src/sha1.o src/websocket.o src/xmalloc.o  -lssl
/usr/bin/ld: src/websocket.o: undefined reference to symbol 'ERR_get_error@@OPENSSL_1_1_0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libcrypto.so.1.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:472: gwsocket] Error 1

OpenSSL 1.1.0 is not available to Ubuntu 20

$ openssl version -a
OpenSSL 1.1.1f  31 Mar 2020
built on: Mon Apr 20 11:53:50 2020 UTC
platform: debian-amd64
options:  bn(64,64) rc4(16x,int) des(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -Wa,--noexecstack -g -O2 -fdebug-prefix-map=/build/openssl-P_ODHM/openssl-1.1.1f=. -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_TLS_SECURITY_LEVEL=2 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2
OPENSSLDIR: "/usr/lib/ssl"
ENGINESDIR: "/usr/lib/x86_64-linux-gnu/engines-1.1"
Seeding source: os-specific
allinurl commented 3 years ago

I think this was addressed upstream. Could you please build from development and see if it happens in there as well.

imatasic commented 3 years ago

Hi, Yes, this was already built from github.

However, I managed to compile it by following this issue and checking what this guy did in his commit. (I have pkg-config installed, if that means anything to you.)

So I added -lcrypto to these two lines in configure file

$ grep -n 'LIBS="-lssl' configure
4080:LIBS="-lssl -lcrypto $LIBS"
4115:  LIBS="-lssl -lcrypto $LIBS"

make now still spews the warnings and notes mentioned above, however doesn't fail on gcc line, and i can run the binary as usual.

P.S. I hate opening another issue for this (I can if you'd like), could you please add some sort of warning when the certificate or private key are not accessible to the user running gwsocket instead of failing silently.

allinurl commented 3 years ago

This has been fixed upstream. It will be pushed out in the upcoming version v0.4.

Closing this. Feel free to reopen it if needed.