### Description Building TLSA module on ubuntu 18.04 results in a compiler warning and an undefined symbol error when attempting to load module.
### Troubleshooting
#### Reproduction Make module and attempt to load it <!-- If the issue can be reproduced, describe how it can be done. -->
#### Debugging Data
<!-- If you got a core dump, use gdb to extract troubleshooting data - full backtrace, local variables and the list of the code at the issue location.
gdb /path/to/kamailio /path/to/corefile bt full info locals list
If you are familiar with gdb, feel free to attach more of what you consider to be relevant. -->
``` N/A ```
#### Log Messages
<!-- Check the syslog file and if there are relevant log messages printed by Kamailio, add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site). --> Compiler output ``` CC (gcc) [M tlsa.so] tls_util.o CC (gcc) [M tlsa.so] tls_domain.o CC (gcc) [M tlsa.so] tls_locking.o CC (gcc) [M tlsa.so] tls_rand.o CC (gcc) [M tlsa.so] tls_map.o CC (gcc) [M tlsa.so] tls_cfg.o CC (gcc) [M tlsa.so] tls_select.o CC (gcc) [M tlsa.so] tls_server.o CC (gcc) [M tlsa.so] tls_dump_vf.o CC (gcc) [M tlsa.so] tls_init.o CC (gcc) [M tlsa.so] tls_rpc.o CC (gcc) [M tlsa.so] tls_config.o CC (gcc) [M tlsa.so] tls_bio.o CC (gcc) [M tlsa.so] tls_ct_wrq.o CC (gcc) [M tlsa.so] tlsa_mod.o CC (gcc) [M tlsa.so] tls_verify.o LD (gcc) [M tlsa.so] tlsa.so /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup': (.text+0x11): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking ```
Kamailio Log ``` Aug 9 11:21:04 kamtest kamailio: ERROR: <core> [core/sr_module.c:570]: load_module(): could not open module </usr/local/lib64/kamailio/modules/tlsa.so>: /usr/local/lib64/kamailio/modules/tlsa.so: undefined symbol: __dlclose Aug 9 11:21:04 kamtest kamailio: CRITICAL: <core> [core/cfg.y:3683]: yyerror_at(): parse error in config file /etc/kamailio/parameters/modules.cfg, line 7, column 12-20: failed to load module Aug 9 11:21:04 kamtest kamailio: ERROR: <core> [core/modparam.c:181]: set_mod_param_regex(): No module matching <tlsa> found ```
#### SIP Traffic
<!-- If the issue is exposed by processing specific SIP messages, grab them with ngrep or save in a pcap file, then add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site). -->
``` N/A ```
### Possible Solutions
<!-- If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a fix. -->
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` version: kamailio 5.6.0-dev0 (x86_64/linux) 0a5307-dirty flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, epoll_lt, epoll_et, sigio_rt, select. id: 0a5307 -dirty compiled on 10:36:16 Aug 9 2021 with gcc 7.5.0 ```
* **Operating System**:
<!-- Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...; Kernel details (output of `uname -a`) -->
``` Linux kamtest 4.15.0-144-generic #148-Ubuntu SMP Sat May 8 02:33:43 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux ```
On Debian 10 Buster works fine.
I have no Ubunto 18.04 around, can you edit the Makefile in the module folder and add `-ldl` to the LIBS? Like:
``` LIBS += -l:libssl.a -l:libcrypto.a -l:libz.a -l:libdl.a -ldl ```
Unfortunatly the additional switches made no effect, i have however found a work around...
If you set the `LIBSSL_STATIC_SRCLIB` to yes, and alter the path to where ubuntu stores the static libs from packages it compiles with no warnings and loads as expected.
``` # set to yes when wanting to link with static libraries compiled from source LIBSSL_STATIC_SRCLIB ?= yes # set to the path of the folder with static libraries compiled from source #LIBSSL_STATIC_SRCPATH ?= /usr/local/src/openssl LIBSSL_STATIC_SRCPATH ?= /usr/lib/x86_64-linux-gnu/ ```
As an aside the emergence of this module and ruxc couldnt be more timely as i have been having no end of problems with random TLS failures which seem to be related to the new "locking" model, so if needs be being able to use an older version of libssl this is perfect, as is an alternative to http_client which has also been having random TLS failures of either accessing priv key or failing while trying to initialise the connection.
Thanks for the info, I added `LIBSSL_STATIC_SRCPATH ?= /usr/lib/x86_64-linux-gnu/` in Makefile comments and reference to Makefile in the readme.
Glad to hear that both tlsa and ruxc are useful. Some old/stable distros _seem to be caught in between stable versions of libssl_ and sometime results in strange/faulty behaviour. Ubuntu 18:04 seems to be one of them, there were other reports on this tracker (eg., with mysql client lib and tls, iirc).
I am going to close this issue. Feel free to propose further enhancements/PRs to Makefile or docs to make it easier overall.
Closed #2815.
Additional notes with ubuntu 18.04
Thought i would try compiling against openssl 1.0.2u to see what effect that had. Although open ssl would compile correctly, tlsa would complain when trying to link against 1.02u.
Solution was to re-rerun the openssl ./config script with the suggested compiler flag in the build error, then rebuild openssl and TLSA
``` test@kamtest:/usr/local/src/openssl-1.0.2u/openssl-1.0.2u$ ./config -fPIC test@kamtest:/usr/local/src/openssl-1.0.2u/openssl-1.0.2u$ make test@kamtest:/usr/local/src/openssl-1.0.2u/openssl-1.0.2u$ make test test@kamtest:/usr/local/src/openssl-1.0.2u/openssl-1.0.2u$ cd ../../kamailio test@kamtest:/usr/local/src/openssl-1.0.2u/openssl-1.0.2u$ make test@kamtest:/usr/local/src/openssl-1.0.2u/openssl-1.0.2u$ sudo make install ```