debug openssl + curl

1. get the openssl and curl source code.

curl-7.37.0.tar.bz2 / openssl-1.0.1g.tar.gz

2. build openssl for debugging:

./config -d shared   // -d for debugging , shared :表示生成libssl.so 等动态链接库, 因为curl 需要使用这个动态库

make
sudo make install
缺省的libssl.so 将会被安装到 /usr/local/ssl/lib/

当前目录下也会有一份,这个对我而言是/home/xuyang/opensslsrc/openssl-1.0.1g

3. build curl

./configure –enable-debug –with-ssl
make
sudo make install

缺省,curl将会被安装到/usr/local/bin/curl

4. debug curl .

env LD_LIBRARY_PATH=/home/xuyang/opensslsrc/openssl-1.0.1g  gdb curl

r https://www.mozilla.org/en-US/

待跑完以后
b ssl3_read
R

即可看到curl将会停到openssl库里面了。下面是一个堆栈:
#0  ssl3_read (s=0x81319d8, buf=0x8090eb4, len=16384) at s3_lib.c:4239
#1  0x00429a49 in SSL_read (s=0x81319d8, buf=0x8090eb4, num=16384) at ssl_lib.c:970
#2  0x0019b89f in ossl_recv (conn=0x80a33ec, num=0, buf=0x8090eb4 “C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 Extended Validation Server CA”,
buffersize=16384, curlcode=0xbfffeac4) at vtls/openssl.c:2767
#3  0x0014a7f6 in Curl_read (conn=0x80a33ec, sockfd=7, buf=0x8090eb4 “C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 Extended Validation Server CA”,
sizerequested=16384, n=0xbfffeb60) at sendf.c:567
#4  0x00164da8 in readwrite_data (data=0x809095c, conn=0x80a33ec, k=0x80909a8, didwhat=0xbfffebe0, done=0xbfffec9c) at transfer.c:426
#5  0x00166069 in Curl_readwrite (conn=0x80a33ec, done=0xbfffec9c) at transfer.c:1050
#6  0x00172a0f in multi_runsingle (multi=0x809a67c, now=…, data=0x809095c) at multi.c:1487
#7  0x001730e0 in curl_multi_perform (multi_handle=0x809a67c, running_handles=0xbfffeddc) at multi.c:1762
#8  0x00168349 in easy_transfer (multi=0x809a67c) at easy.c:709
#9  0x001684f6 in easy_perform (data=0x809095c, events=false) at easy.c:797
#10 0x0016853e in curl_easy_perform (easy=0x809095c) at easy.c:816
#11 0x08058ff9 in operate_do (global=0xbffff250, config=0x808102c) at tool_operate.c:1371
#12 0x08059ea0 in operate (config=0xbffff250, argc=2, argv=0xbffff334) at tool_operate.c:1839
#13 0x08053acb in main (argc=2, argv=0xbffff334) at tool_main.c:239

 



本文地址: http://www.bagualu.net/wordpress/archives/3514 转载请注明




发表评论

电子邮件地址不会被公开。 必填项已用*标注