I compiled OpenSSL 0.9.8x with these ./config options:
./config --prefix=/usr/local/openssl-0.9.8 --openssldir=/usr/local/openssl-0.9.8
I’m compiling my PHP version with these ./configure options (among others):
--with-openssl=/usr/local/openssl-0.9.8
--with-openssl-dir=/usr/local/openssl-0.9.8
The problem is that when I run a PHP script with openssl_public_encrypt
I’m getting a segmentation fault.
Here’s what gdb says:
Program terminated with signal 11, Segmentation fault.
#0 0x00007fd3381c5a48 in RSA_public_encrypt () from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
In /usr/local/openssl-0.9.8/lib/ there’s libcrypto.so.0.9.8 so why isn’t it using that?
Here’s my OpenSSL Makefile:
Here’s my PHP Makefile:
Here’s a Dockefile that reproduces the issue:
Any ideas? Thanks!
2
Answers
The problem is that ld-linux resolves the link at runtime to the wrong library.
Try to execute it by setting LD_LIBRARY_PATH:
LD_LIBRARY_PATH=/usr/local/openssl-0.9.8/lib php very_old_php_44_script_which_shall_not_be_used.php
If it works you might want to execute it using:
LD_DEBUG=all php ...
to check where and why the dynamic linker does not use the 0.9.8 openssl version.Use
LD_LIBRARY_PATH
will fix the problem in general, but not for yours in this case.I have rewritten the Dockerfile based on yours in order to fix the segfault.
Remove both
--disable-rpath
and--libdir
arguments on configure phase of PHP.We use
rpath
to locate shared objects at runtime for custom build openssl on /usr/local/openssl-0.9.8x.See option
-rpath=dir
from https://linux.die.net/man/1/ldAdd
shared
option to config script of OpenSSLTo build share libraries (libcrypto.so.0.9.8 and libssl.so.0.9.8)
Link kerberos libraries only in /usr/kerberos/lib
Instead of linking all libraries from /usr/lib/x86_64-linux-gnu to /usr/kerberos/lib, The ordering of runtime search path is
/usr/kerberos/lib:/usr/local/openssl-0.9.8/lib
Here is the changes
test.php
Result