openresty / encrypted-session-nginx-module

encrypt and decrypt nginx variable values
http://openresty.org
198 stars 52 forks source link

undefined symbol: MD5 #11

Closed alexmango closed 7 years ago

alexmango commented 7 years ago

I have try to use this module as a dynamic module,but when i start nginx, occur an error: dlopen() "/data/services/nginx-1.10.2/modules/ngx_http_encrypted_session_module.so" failed (/data/services/nginx-1.10.2/modules/ngx_http_encrypted_session_module.so: undefined symbol: MD5) in /data/services/nginx-1.10.2/conf/nginx.conf

operating system:Ubuntu 12.04 LTS 64bit nginx version: nginx 1.10.2 encrypted-session-nginx-module version:0.06 gcc version: 4.6.3 configure command: ./configure --user=www-data --group=www-data --prefix=/data/services/nginx-1.10.2 \ --with-http_ssl_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_sub_module \ --with-http_dav_module \ --with-http_flv_module \ --with-http_mp4_module \ --with-http_gzip_static_module \ --with-http_random_index_module \ --with-http_secure_link_module \ --with-http_stub_status_module \ --with-file-aio \ --with-stream \ --with-stream_ssl_module \ --with-pcre=../pcre-8.39 \ --with-openssl=../openssl-1.0.2j \ --with-zlib=../zlib-1.2.8 \ --add-dynamic-module=../nginx_module/ngx_devel_kit-0.3.0 \ --add-dynamic-module=../nginx_module/encrypted-session-nginx-module-0.06

nginx.conf: load_module modules/ndk_http_module.so; load_module modules/ngx_http_encrypted_session_module.so;

It seems that nginx can't find the function that is named MD5.

I try to use nm to list function,show below nm libcrypto.a |grep MD5 0000000000000230 T MD5_Final 00000000000002e0 T MD5_Init 0000000000000220 T MD5_Transform 0000000000000000 T MD5_Update 0000000000000000 R MD5_version 0000000000000000 T MD5

nm nginx|grep MD5 000000000051e050 T MD5_Final 000000000051e100 T MD5_Init 000000000051e040 T MD5_Transform 000000000051de20 T MD5_Update 0000000000680960 R MD5_version

MD5 function is exists in libcrypto.a ,but it is not exists in nginx.

agentzh commented 7 years ago

@alexmango Better link against openssl (including libcrypto) dynamically instead of statically. My hunch is that the linker omits MD5 since it does not find any uses of that symbol during the (static) linking phase.

alexmango commented 7 years ago

@agentzh ,Thank you. The --with-openssl options force compile openssl statically .How to compile dynamically ?

agentzh commented 7 years ago

@alexmango Well, this is already beyond the scope of this nginx C module. It's very basic stuff.

Just build and install openssl yourself like below:

cd openssl-1.0.2j/
./config -g shared --prefix=/opt/ssl102
make -j4
sudo make install_sw

And then build nginx like below:

./configure --with-http_ssl_module \
    --with-cc-opt="-I/opt/ssl102" \
    --with-ld-opt="-L/opt/ssl102 -Wl,-rpath,/opt/ssl/102" \
    ...

Just do not use the --with-openssl=PATH option here.