ERROR: tls [tls_init.c:601]: tls_pre_init(): Unable to set the memory allocation functions
This error comes with 5.0x - 5.2x and maybe in earlyer versions too. Tried OpenSSL 1.0, and 1.1 with same result...
Are you tested on reference kamailio config or used custom config?
This is probably something related opensuse leap 15.0 (if this matches the earlier email on sr-users).
I was able to reproduce this on opensuse 42.3 with the default kamailio cfg.
$ ./kamailio -f ../etc/kamailio.cfg -E -e -L modules -Y /tmp/ -AWITH_TLS -AWITH_DEBUG
0(12645) ERROR: tls [tls_init.c:601]: tls_pre_init(): Unable to set the memory allocation functions 0(12645) ERROR: tls [tls_init.c:603]: tls_pre_init(): libssl current mem functions - m: 0x7f613089c380 r: 0x7f613089c9e0 f: 0x7f613089c950 0(12645) ERROR: tls [tls_init.c:605]: tls_pre_init(): Be sure tls module is loaded before any other module using libssl (can be loaded first to be safe) 0(12645) ERROR: <core> [core/sr_module.c:532]: load_module(): modules/tls/tls.so: mod_register failed
$ rpm -qi libopenssl-devel Name : libopenssl-devel Version : 1.0.2j Release : 32.1 Architecture: x86_64
$ ldd tls.so linux-vdso.so.1 (0x00007ffd9ad8d000) libssl.so.1.0.0 => /lib64/libssl.so.1.0.0 (0x00007f619dc34000) libc.so.6 => /lib64/libc.so.6 (0x00007f619d88f000) libcrypto.so.1.0.0 => /lib64/libcrypto.so.1.0.0 (0x00007f619d436000) /lib64/ld-linux-x86-64.so.2 (0x00007f619e135000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f619d232000) libz.so.1 => /lib64/libz.so.1 (0x00007f619d01c000)
There were some versions of openssl that had a bug in setting custom memory management functions. It was discussed on sr-users mailing list as well as in the issue:
* https://github.com/kamailio/kamailio/issues/714
As I see this issue mets a lot of different versions of OpenSSL / Kamailio TLS module Does anyone knows which versions of OpenSSL are compatible with Kamailio 5.0.x?
I use TLS with `kamailio:5.1` branch and OpenSSL 1.1.1a If info about 5.1 branch acceptable for you.
I use TLS with `kamailio:5.1` branch and OpenSSL 1.1.1a If info about 5.1 branch acceptable for you.
Will test it, thank you :-)
On other hand I see OpenSUSE Leap 15 comes with: - libopenssl1_0_0-1.0.2n-lp150.1.25 - libopenssl1_1-1.1.0h-lp150.2.1
The tls module is compiled against: - libssl.so.1.0.0 - libcrypto.so.1.0.0 ...
I think i will try a libopenssl version lower as 1.0.2j0, which henningw has tested..
Will inform :-)
OpenSSL 1.1.1a
I use TLS with `kamailio:5.1` branch and OpenSSL 1.1.1a If info about 5.1 branch acceptable for you.
Sergey,
did you compile the tls module against libopenssl-1.1.1 ?
I use "Alpine edge" dist with openssl and kamailio versions described above.
Old [mail thread](https://lists.kamailio.org/pipermail/sr-users/2013-August/079407.html) from 2013 with a test program:
``` #include <stdio.h> #include <openssl/ssl.h>
static void *myMalloc( size_t s ) { return NULL; } static void *myRealloc( void *p, size_t s ) { return NULL; } static void myFree( void *p ) {}
int main() { if ( !CRYPTO_set_mem_functions( myMalloc, myRealloc, myFree) ) { fprintf( stderr, "Unable to set the memory allocation functions\n"); return -1; } return 0; }
``` Compile with: `gcc -o testssl testssl.c -lssl -lcrypto`
On the opensuse 42.3: $ ./testssl Unable to set the memory allocation functions
It seems this error is related to the FIPS support in the opensuse openssl 1.0.x.
- [bug ubuntu](https://bugs.launchpad.net/ubuntu/+source/openssl/+bug/1594748) - [bug python](https://bugs.python.org/issue18227)
$ openssl version OpenSSL 1.0.2j-fips 26 Sep 2016
[Link suse.com](https://www.suse.com/c/fipsified/)
So as already mentioned, it seems that the openssl version shipped with Opensuse 42.3 is not usable for the tls module. Funny fact, if you disable the FIPS mode, openssl actually aborts directly:
export OPENSSL_FORCE_FIPS_MODE="0" $ LANG=C; openssl version -v fips.c(139): OpenSSL internal error, assertion failed: FATAL FIPS SELFTEST FAILURE Aborted (core dumped)
Closing this one, not being something that can be done in Kamailio. However, if someone finds an workaround for doing something inside kamailio, just make a pull request.
Closed #1797.