Closed dengbq1234 closed 2 years ago
我在Linux下测试了以下过程是可以的:
$cd hird_party/mbedtls-2.7.12/library;
$export SHARED=1; make
$cp *.so ~/acl/lib_acl_cpp/samples/ssl/
$cd ~/acl/lib_acl_cpp/samples/ssl/ssl_server/
$vi ssl_server.cpp # 把其中中的宏定义 "#define USE_ONE" 注释掉,以便使用三个独立的 so 库
$make
$./t.sh
然后会显示:
mbedtls_conf.cpp(405), mbedtls_dll_load: ../libmbedcrypto.so loaded!
mbedtls_conf.cpp(407), mbedtls_dll_load: ../libmbedx509.so loaded!
mbedtls_conf.cpp(410), mbedtls_dll_load: ../libmbedtls.so loaded!
listen: 0.0.0.0:2443 ...
event_limit: fdsize(1024) too small, extend it
event_limit: max fdsize: 10240
acl_inet_listen: listen 0.0.0.0:2443 ok
ssl_server.cpp(374), proc_on_init: load cert ok, crt: ../ssl_crt.pem
ssl_server.cpp(383), proc_on_init: set key ok, key: ../ssl_key.pem
deng@ubuntu:~/work/opensource/acl-master/lib_acl_cpp/samples/ssl/ssl_server$ ll ..
总用量 768
drwxrwxr-x 15 deng deng 4096 7月 21 09:09 ./
drwxrwxr-x 89 deng deng 4096 7月 14 09:12 ../
drwxrwxr-x 2 deng deng 4096 7月 20 09:15 aio_client/
drwxrwxr-x 2 deng deng 4096 7月 19 09:18 aio_server/
drwxrwxr-x 2 deng deng 4096 7月 14 09:12 client/
drwxrwxr-x 2 deng deng 4096 7月 18 17:40 https_client/
drwxrwxr-x 2 deng deng 4096 7月 18 17:40 https_proxy/
drwxrwxr-x 2 deng deng 4096 7月 14 09:12 https_request/
drwxrwxr-x 2 deng deng 4096 7月 14 09:12 https_request_static/
drwxrwxr-x 2 deng deng 4096 7月 18 17:40 https_server/
-rwxrwxr-x 1 deng deng 402160 7月 21 09:09 libmbedcrypto.so
-rwxrwxr-x 1 deng deng 190776 7月 21 09:09 libmbedtls.so
-rwxrwxr-x 1 deng deng 97608 7月 21 09:09 libmbedx509.so*
-rw-rw-r-- 1 deng deng 448 7月 14 09:12 Makefile
-rw-rw-r-- 1 deng deng 155 7月 14 09:12 README.md
drwxrwxr-x 2 deng deng 4096 7月 20 14:54 server/
drwxrwxr-x 2 deng deng 4096 7月 21 09:11 ssl_client/
drwxrwxr-x 2 deng deng 4096 7月 18 17:40 ssl_client2/
-rw-rw-r-- 1 deng deng 1054 7月 20 14:53 ssl_crt.pem
-rw-rw-r-- 1 deng deng 1704 7月 20 14:53 ssl_key.pem
drwxrwxr-x 2 deng deng 4096 7月 21 09:16 ssl_server/
drwxrwxr-x 2 deng deng 4096 7月 18 17:40 ssl_server2/
-rw------- 1 deng deng 1675 7月 20 14:43 sslserver.key
-rw-rw-r-- 1 deng deng 4561 7月 20 14:43 sslserver.pem
deng@ubuntu:~/work/opensource/acl-master/lib_acl_cpp/samples/ssl/ssl_server$ ./t.sh
acl_dlopen(36): open(../libmbedx509.so) error(Success)
mbedtls_conf.cpp(357), load_all_dlls: load ../libmbedx509.so error ../libmbedx509.so: undefined symbol: mbedtls_threading_gmtime_mutex
mbedtls_conf.cpp(505), load: load mbedtls error
load ../libmbedtls.so error
deng@ubuntu:~/work/opensource/acl-master/lib_acl_cpp/samples/ssl/ssl_server$ nm ../libmbed
libmbedcrypto.so libmbedtls.so libmbedx509.so
deng@ubuntu:~/work/opensource/acl-master/lib_acl_cpp/samples/ssl/ssl_server$ nm ../libmbedcrypto.so |grep mbedtls_threading_gmtime_mutex
0000000000255ba0 D mbedtls_threading_gmtime_mutex
deng@ubuntu:~/work/opensource/acl-master/lib_acl_cpp/samples/ssl/ssl_server$ nm ../libmbedx509.so |grep mbedtls_threading_gmtime_mutex
U mbedtls_threading_gmtime_mutex
mbedtls生成的库有问题
mbedtls是按你说的方法,在third_part/mbedtls27/library/下重新生成的。 ![Uploading 123.png…]()
Ubuntu 18
----- 原始邮件 ----- 发件人:郑树新 @.> 收件人:acl-dev/acl @.> 抄送人:dengbq1234 @.>, Author @.> 主题:Re:_[acl-dev/acl]ssl怎样正常工作(Issue_#285) 日期:2022年07月20日 23点06分
你是在Mac上还是Linux使用?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
看来在Ubuntu下编译的mbedtls的三个 so 不能很好地动态加载,不过我找到一个变通的方式,通过以下方式就可以解决了:
$mkdir mbedtls-2.7.12/build
$cd mbedtls-2.7.12/build
$cmake ..; make -j 4
$cd ../lib
$cp libmbedtls_all.so libmbedcrypto.so
$cp libmbedtls_all.so libmbedx509.so
$cp libmbedtls_all.so libmbedtls.so
然后把上面的三个 so(libmbedcrypto.so, libmbedx509.so, libmbedtls.so)拷贝到 SSL 程序的运行目录下,就可以正常加载了。 这个 CMakeLists.txt 是我之前写的,把mbedtls里所有的源文件编译成一个统一的库(libmbedtls_all.so)。
多谢大神的及时答复,终于可以加载成功了。
lib_acl_cpp/samples/ssl/sslserver示例编译不过,一看是sslconf.open出错,修改为sslconf.create后编译过了,再编译third_party里面的mbedtls27,把库拷贝过来,加载时报: acl_dlopen(36): open(../libmbedx509.so) error(Success) mbedtls_conf.cpp(357), load_all_dlls: load ../libmbedx509.so error ../libmbedx509.so: undefined symbol: mbedtls_threading_gmtime_mutex mbedtls_conf.cpp(505), load: load mbedtls error load ../libmbedcrypto.so,../libmbedx509.so,../libmbedtls.so error. 换成mbedtls 3.21版本编译后,再运行: ./server -L "../libmbedcrypto.so,../libmbedx509.so,../libmbedtls.so" mbedtls_conf.cpp(405), mbedtls_dll_load: ../libmbedcrypto.so loaded! mbedtls_conf.cpp(407), mbedtls_dll_load: ../libmbedx509.so loaded! mbedtls_conf.cpp(410), mbedtls_dll_load: ../libmbedtls.so loaded! server: malloc.c:2401: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed. 已放弃 (核心已转储)