[Libwebsockets] working with wolfssl

Trey Weaver treyweaver at fastmail.net
Mon May 10 21:46:38 CEST 2021


Andy, your email helped!

For some reason the wolfssl was not building with the openssl api even though I had the --enable-opensslextra option on.  So I got past that issue.

I am compiling on the Arm (iMX6 -- Solid Run Module) both the WolfSSL and libwebsockets.  Here are the cmake and configure for both.

WolfSSL
./configure --enable-opensslextra --enable-static –-enable-debug --enable-examples --enable-harden --host=arm-linux-gnueabihf --enable-hc128 

libwebsockets
cmake -DLWS_WITH_SHARED:BOOL=OFF -DLWS_WITH_WOLFSSL=1 -DLWS_WOLFSSL_INCLUDE_DIRS=/home/jps/Development/wolfssl-4.4.0 -DLWS_WOLFSSL_LIBRARIES=/home/jps/Development/wolfssl-4.4.0/src/.libs/libwolfssl.a ..

But now when I do a compile I get the following error:
(Note:  I tried with both the libwolfssl.so and libwolfssl.a)

[ 14%] Building C object lib/CMakeFiles/websockets.dir/tls/openssl/openssl-tls.c.o
In file included from /home/jps/Development/libwebsockets-4.2/libwebsockets/include/libwebsockets.h:273,
                 from /home/jps/Development/libwebsockets-4.2/libwebsockets/lib/core/./private-lib-core.h:140,
                 from /home/jps/Development/libwebsockets-4.2/libwebsockets/lib/tls/openssl/openssl-tls.c:25:
/home/jps/Development/libwebsockets-4.2/libwebsockets/lib/tls/openssl/openssl-tls.c: In function ‘lws_context_init_ssl_library’:
/home/jps/Development/wolfssl-4.4.0/wolfssl/openssl/ssl.h:644:41: error: implicit declaration of function ‘wolfSSL_get_ex_new_index’; did you mean ‘wolfSSL_CTX_get_ex_new_index’? [-Werror=implicit-function-declaration]
 #define SSL_get_ex_new_index            wolfSSL_get_ex_new_index
                                         ^~~~~~~~~~~~~~~~~~~~~~~~
/home/jps/Development/libwebsockets-4.2/libwebsockets/lib/tls/openssl/openssl-tls.c:158:4: note: in expansion of macro ‘SSL_get_ex_new_index’
    SSL_get_ex_new_index(0, "lws", NULL, NULL, NULL);
    ^~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

I am begging to think I should abandon WolfSSL, I have been at this for days!

Regards,
Trey Weaver


On Mon, May 10, 2021, at 9:41 AM, Andy Green wrote:
> 
> 
> On 5/10/21 2:25 PM, Trey Weaver wrote:
> > When I do a straight up:
> > *cmake ..*
> > *make*
> > 
> > everything goes fine.  But when I try to add the wolfssl stuff like this:
> > 
> > cmake -DLWS_WITH_WOLFSSL=1 
> > -DLWS_WOLFSSL_INCLUDE_DIRS=/home/jps/Temp/wolfssh.headers 
> > -DLWS_WOLFSSL_LIBRARIES=/usr/share/jps-audioproc-third-party/wolfssl/lib/libwolfssl.a 
> > ..
> > 
> > just like the build notes say to do and then do a make then I get this 
> > error:
> > 
> > *jps at dsp:~/Development/libwebsockets-4.2/libwebsockets/build$ make*
> > *Scanning dependencies of target GENHDR*
> > *[  0%] Creating build include dir*
> > *[  0%] Built target GENHDR*
> > *Scanning dependencies of target websockets_shared*
> > *[  1%] Building C object 
> > lib/CMakeFiles/websockets_shared.dir/plat/unix/unix-caps.c.o*
> > *In file included from 
> > /home/jps/Development/libwebsockets-4.2/libwebsockets/include/libwebsockets.h:642,*
> > *                 from 
> > /home/jps/Development/libwebsockets-4.2/libwebsockets/lib/core/./private-lib-core.h:140,*
> > *                 from 
> > /home/jps/Development/libwebsockets-4.2/libwebsockets/lib/plat/unix/unix-caps.c:28:*
> > */home/jps/Development/libwebsockets-4.2/libwebsockets/include/libwebsockets/lws-genhash.h:85:9: 
> > error: unknown type name ‘HMAC_CTX’*
> > *         HMAC_CTX ctx;*
> > *         ^~~~~~~~*
> > *make[2]: *** [lib/CMakeFiles/websockets_shared.dir/build.make:63: 
> > lib/CMakeFiles/websockets_shared.dir/plat/unix/unix-caps.c.o] Error 1*
> > *make[1]: *** [CMakeFiles/Makefile2:1076: 
> > lib/CMakeFiles/websockets_shared.dir/all] Error 2*
> > *make: *** [Makefile:163: all] Error 2*
> > 
> > I am building 4.2 on a 32 bit ARM (iMX6).
> 
> So it's a native build actually on the arm device?
> 
> > I do see this in CMAKE:
> > 
> > *-- Looking for wolfSSL_HMAC_CTX_new
> > *
> > *-- Looking for wolfSSL_HMAC_CTX_new - not found
> > *
> > 
> > I did compile wolfssl with the --enable-opensslextra option.
> > 
> > I have attached the cmake output file....I don't know why every wolfssl 
> > option is "not found" or if that is normal.
> 
> Most of them are "not found" on the CI build, eg
> 
> https://libwebsockets.org/sai/index.html?task=dcd069b73fe7a306bdc9566b47de8c581f1a0df21fecf541678c6155c4ef1954
> 
> ... but there are like 5 or so that are found when built on x86_64 in 
> CI, particularly
> 
> -- Looking for wolfSSL_HMAC_CTX_new
> -- Looking for wolfSSL_HMAC_CTX_new - found
> 
> It should have emitted something like this on stdout (I think)
> 
> Compiling with SSL support
> wolfSSL include dir: /usr/local/include
> wolfSSL libraries: /usr/local/lib/libwolfssl.so
> 
> I would look into exactly what you have in
> 
> /home/jps/Temp/wolfssh.headers
> 
> it should contain a subdir wolfssl/ that has a bunch of .h, an openssl 
> subdir inside wolfssl/ etc.
> 
> If that looks OK, then you need to go look in whatever your equivalent 
> of ./build/CMakeFiles/CMakeError.log is, and find the test it did for 
> wolfSSL_HMAC_CTX_new(), and paste what happened with that test.  The 
> test builds that CMake does to determine api existence are allowed to 
> fail, then it takes the failure to mean that the api it was looking for 
> doesn't exist.  But there are many reasons the tests can fail to build, 
> eg, missing library so it can't link.
> 
> Also in CI, it is dynamically linking to the .so version of Wolfssl, you 
> might try that.
> 
> -Andy
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets
> 


More information about the Libwebsockets mailing list