eclipse / paho.mqtt.c

An Eclipse Paho C client library for MQTT for Windows, Linux and MacOS. API documentation: https://eclipse.github.io/paho.mqtt.c/
https://eclipse.org/paho
Other
1.97k stars 1.1k forks source link

Paho 1.3.10 doesn't compile with openssl 3.0.3 #1242

Open mjj29 opened 2 years ago

mjj29 commented 2 years ago

Openssl 1.1 is going out of support in a year. We'd like to move our product to 3.0.3, but Paho doesn't seem to build against it. The error message I get is:

cc -g -fPIC -O3 -D_GNU_SOURCE -Os -Wall -fvisibility=hidden -Ibuild -DPAHO_MQTT_EXPORTS=1 -o build/output/libpaho-mqtt3as.so.1.3 src/Heap.c src/Socket.c src/SSLSocket.c src/MQTTAsyncUtils.c src/MQTTProtocolClient.c src/MQTTProtocolOut.c src/SHA1.c src/MQTTAsync.c src/MQTTPersistenceDefault.c src/MQTTTime.c src/MQTTP acketOut.c src/Thread.c src/WebSocket.c src/MQTTReasonCodes.c src/Clients.c src/OsWrapper.c src/MQTTPacket.c src/Messages.c src/MQTTPersistence.c src/Base64.c src/Log.c src/StackTrace.c src/LinkedList.c src/utf-8.c src/MQTTProperties.c src/SocketBuffer.c src/Proxy.c src/Tree.c -DOPENSSL -L/work/mjj29/apama-lib5/bran ched/linux/amd64/10.15.0.x/openssl/3.0.3/lib64 -I/work/mjj29/apama-lib5/branched/all/10.15.0.x/openssl/3.0.3/include/ -shared -Wl,--start-group -pthread -lanl -ldl -lssl -lcrypto -Wl,--end-group -Wl,-init,MQTTAsync_init -Wl,-soname,libpaho-mqtt3as.so.1 -Wl,-no-whole-archive src/SSLSocket.c:65:26: error: unknown type name ‘CRYPTO_THREADID’; did you mean ‘CRYPTO_THREAD_ID’? extern void SSLThread_id(CRYPTO_THREADID id); ^~~~~~~ CRYPTO_THREAD_ID src/SSLSocket.c: In function ‘SSLSocket_error’: src/SSLSocket.c:114:9: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] if (strcmp(aString, "shutdown") != 0) ^~ src/SSLSocket.c:116:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ if (error == SSL_ERROR_SSL || error == SSL_ERROR_SYSCALL) ^~ src/SSLSocket.c: At top level: src/SSLSocket.c:403:26: error: unknown type name ‘CRYPTO_THREADID’; did you mean ‘CRYPTO_THREAD_ID’? extern void SSLThread_id(CRYPTO_THREADID id) ^~~~~~~ CRYPTO_THREAD_ID src/SSLSocket.c: In function ‘SSLLocks_callback’: src/SSLSocket.c:426:14: error: ‘CRYPTO_LOCK’ undeclared (first use in this function); did you mean ‘CRYPTO_RWLOCK’? if (mode & CRYPTO_LOCK) ^~~ CRYPTO_RWLOCK src/SSLSocket.c:426:14: note: each undeclared identifier is reported only once for each function it appears in src/SSLSocket.c: In function ‘SSLSocket_initialize’: src/SSLSocket.c:451:13: warning: implicit declaration of function ‘SSL_library_init’; did you mean ‘SSL_in_init’? [-Wimplicit-function-declaration] if ((rc = SSL_library_init()) != 1)

         SSL_in_init

src/SSLSocket.c:454:3: warning: implicit declaration of function ‘ERR_load_crypto_strings’; did you mean ‘ERR_load_SSL_strings’? [-Wimplicit-function-declaration] ERR_load_crypto_strings(); ^~~~~~~ ERR_load_SSL_strings src/SSLSocket.c:455:3: warning: implicit declaration of function ‘SSL_load_error_strings’; did you mean ‘ERR_lib_error_string’? [-Wimplicit-function-declaration] SSL_load_error_strings(); ^~~~~~ ERR_lib_error_string src/SSLSocket.c:461:3: warning: implicit declaration of function ‘OpenSSL_add_all_algorithms’; did you mean ‘OBJ_id_tc26_algorithms’? [-Wimplicit-function-declaration] OpenSSL_add_all_algorithms(); ^~~~~~ OBJ_id_tc26_algorithms src/SSLSocket.c:463:17: warning: implicit declaration of function ‘CRYPTO_num_locks’; did you mean ‘CRYPTO_realloc’? [-Wimplicit-function-declaration] lockMemSize = CRYPTO_num_locks() * sizeof(ssl_mutex_type); ^~~~ CRYPTO_realloc src/SSLSocket.c:480:3: warning: implicit declaration of function ‘CRYPTO_THREADID_set_callback’; did you mean ‘CRYPTO_THREAD_set_local’? [-Wimplicit-function-declaration] CRYPTO_THREADID_set_callback(SSLThread_id); ^~~~~~~~ CRYPTO_THREAD_set_local src/SSLSocket.c:480:32: error: ‘SSLThread_id’ undeclared (first use in this function); did you mean ‘SSL_read_ex’? CRYPTO_THREADID_set_callback(SSLThread_id); ^~~~ SSL_read_ex src/SSLSocket.c:484:3: warning: implicit declaration of function ‘CRYPTO_set_locking_callback’; did you mean ‘BIO_set_info_callback’? [-Wimplicit-function-declaration] CRYPTO_set_locking_callback(SSLLocks_callback); ^~~~~~~ BIO_set_info_callback src/SSLSocket.c: In function ‘SSLSocket_terminate’: src/SSLSocket.c:504:3: warning: implicit declaration of function ‘ERR_free_strings’; did you mean ‘ERR_load_strings’? [-Wimplicit-function-declaration] ERR_free_strings(); ^~~~ ERR_load_strings src/SSLSocket.c:505:3: warning: implicit declaration of function ‘EVP_cleanup’; did you mean ‘EVP_PBE_cleanup’? [-Wimplicit-function-declaration] EVP_cleanup(); ^~~ EVP_PBE_cleanup src/MQTTAsync.c: In function ‘MQTTAsync_getVersionInfo’: src/MQTTAsync.c:1726:23: warning: implicit declaration of function ‘SSLeay_version’; did you mean ‘SSL_version’? [-Wimplicit-function-declaration] libinfo[i++].value = SSLeay_version(SSLEAY_VERSION); ^~~~~~ SSL_version src/MQTTAsync.c:1726:38: error: ‘SSLEAY_VERSION’ undeclared (first use in this function); did you mean ‘SSL2_VERSION’? libinfo[i++].value = SSLeay_version(SSLEAY_VERSION); ^~~~~~ SSL2_VERSION src/MQTTAsync.c:1726:38: note: each undeclared identifier is reported only once for each function it appears in src/MQTTAsync.c:1729:38: error: ‘SSLEAY_CFLAGS’ undeclared (first use in this function); did you mean ‘OPENSSL_CFLAGS’? libinfo[i++].value = SSLeay_version(SSLEAY_CFLAGS); ^~~~~ OPENSSL_CFLAGS src/MQTTAsync.c:1732:38: error: ‘SSLEAY_BUILT_ON’ undeclared (first use in this function); did you mean ‘OPENSSL_BUILT_ON’? libinfo[i++].value = SSLeay_version(SSLEAY_BUILT_ON); ^~~~~~~ OPENSSL_BUILT_ON src/MQTTAsync.c:1735:38: error: ‘SSLEAY_PLATFORM’ undeclared (first use in this function); did you mean ‘OPENSSL_PLATFORM’? libinfo[i++].value = SSLeay_version(SSLEAY_PLATFORM); ^~~~~~~ OPENSSL_PLATFORM src/MQTTAsync.c:1738:38: error: ‘SSLEAY_DIR’ undeclared (first use in this function); did you mean ‘SSL_OP_BIT’? libinfo[i++].value = SSLeay_version(SSLEAY_DIR); ^~~~~~ SSL_OP_BIT In file included from src/Base64.c:43: src/Base64.c: In function ‘Base64_encodeDecode’: /work/mjj29/apama-lib5/branched/all/10.15.0.x/openssl/3.0.3/include/openssl/bio.h:564:34: warning: value computed is not used [-Wunused-value]

define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)

                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/Base64.c:71:3: note: in expansion of macro ‘BIO_flush’ BIO_flush(b_out); / indicate end of encoding / ^~~~~ src/Log.c:396:13: warning: ‘Log_trace’ defined but not used [-Wunused-function] static void Log_trace(enum LOG_LEVELS log_level, const char *buf) ^~~~~ gmake: *** [Makefile:269: build/output/libpaho-mqtt3as.so.1.3] Error 1

NicoWallmeier commented 1 year ago

I was able to compile paho 1.3.12 with OpenSSL 3.0.8 without problems. I only saw three deprecation warning regarding OpenSSL3...

icraggs commented 1 year ago

This build https://github.com/eclipse/paho.mqtt.c/actions/runs/4713216246/jobs/8358777422 is against OpenSSL 3.0.2, There are deprecation warnings for:

WebSocket.c:1324:17: warning: ‘SHA1_Init’ is deprecated: Since OpenSSL 3.0 WebSocket.c:1325:17: warning: ‘SHA1_Update’ is deprecated: Since OpenSSL 3.0 WebSocket.c:1326:17: warning: ‘SHA1_Final’ is deprecated: Since OpenSSL 3.0

which are for the WebSocket handshake, not TLS. Those deprecations should be addressed in 1.4 though.

korolew commented 7 months ago

I got this error (and warnings) while trying to cross-compile Paho 1.3.13 with OpenSSL 3.0.13:

/paho.mqtt.c/src/WebSocket.c:1316:3: error: unknown type name 'SHA_CTX'; did you mean 'SCT_CTX'?
#53 6.001  1316 |   SHA_CTX ctx;
#53 6.001       |   ^~~~~~~
#53 6.001       |   SCT_CTX

#53 6.004 /paho.mqtt.c/src/WebSocket.c:1324:3: warning: implicit declaration of function 'SHA1_Init' [-Wimplicit-function-declaration]
#53 6.004  1324 |   SHA1_Init( &ctx );
#53 6.004       |   ^~~~~~~~~
#53 6.008 /paho.mqtt.c/src/WebSocket.c:1325:3: warning: implicit declaration of function 'SHA1_Update' [-Wimplicit-function-declaration]
#53 6.008  1325 |   SHA1_Update( &ctx, ws_key, strlen(ws_key));
#53 6.008       |   ^~~~~~~~~~~
#53 6.012 /paho.mqtt.c/src/WebSocket.c:1326:3: warning: implicit declaration of function 'SHA1_Final' [-Wimplicit-function-declaration]
#53 6.012  1326 |   SHA1_Final( sha_hash, &ctx );
#53 6.012       |   ^~~~~~~~~~
DaidaiMunters commented 2 months ago

Hi, Is there any updates for this issue? I am trying to compile static lib with ssl and getting the same error as @korolew.

And I am still looking for any possible solution for it.

I am using openssl 3.0.14.

DaidaiMunters commented 1 month ago

I got this error (and warnings) while trying to cross-compile Paho 1.3.13 with OpenSSL 3.0.13:

/paho.mqtt.c/src/WebSocket.c:1316:3: error: unknown type name 'SHA_CTX'; did you mean 'SCT_CTX'?
#53 6.001  1316 |   SHA_CTX ctx;
#53 6.001       |   ^~~~~~~
#53 6.001       |   SCT_CTX

#53 6.004 /paho.mqtt.c/src/WebSocket.c:1324:3: warning: implicit declaration of function 'SHA1_Init' [-Wimplicit-function-declaration]
#53 6.004  1324 |   SHA1_Init( &ctx );
#53 6.004       |   ^~~~~~~~~
#53 6.008 /paho.mqtt.c/src/WebSocket.c:1325:3: warning: implicit declaration of function 'SHA1_Update' [-Wimplicit-function-declaration]
#53 6.008  1325 |   SHA1_Update( &ctx, ws_key, strlen(ws_key));
#53 6.008       |   ^~~~~~~~~~~
#53 6.012 /paho.mqtt.c/src/WebSocket.c:1326:3: warning: implicit declaration of function 'SHA1_Final' [-Wimplicit-function-declaration]
#53 6.012  1326 |   SHA1_Final( sha_hash, &ctx );
#53 6.012       |   ^~~~~~~~~~

So I managed to fix this issue: