我正在使用 openssl
源代码中的 apps/s_client.c
。我想做一些更改并运行它,但是在我保存文件并执行 make all
或 make
后我的更改没有得到反射(reflect)。
例如,我将 sc_usage
函数更改为:
BIO_printf(bio_err,"This is how you use s_client\n");
BIO_printf(bio_err,"usage: s_client args\n");
BIO_printf(bio_err,"\n");
BIO_printf(bio_err," -host host - use -connect instead\n");
BIO_printf(bio_err," -port port - use -connect instead\n");
然后我在 apps
文件夹中保存并执行 make all
,但是当我通过这样做运行程序时:openssl s_client abc
,我没有在输出中看到我介绍的行,this is how you use s_client
。
我哪里错了?
最佳答案
I want to make a few changes and run it, but my changes are not getting reflected after I save the file and do a make all, or a make.
一旦你知道了技巧,它甚至比这更容易。
- 正常配置 OpenSSL 库(
配置
) - 正常构建 OpenSSL 库(
make depend && make
) - 正常安装 OpenSSL 库(
sudo make install
) - 对
s_client.c
进行更改 - 就地编译
s_client.c
(apps/
目录):
这是油脂。您必须构建一些额外的目标文件,例如 apps.o
和 apps_rand.o
,以支持 s_client.o
。
export OPENSSLDIR=/usr/local/ssl/darwin
gcc -DOPENSSL_NO_PSK -DMONOLITH -I$OPENSSLDIR/include -I../ -c apps.c
gcc -DOPENSSL_NO_PSK -DMONOLITH -I$OPENSSLDIR/include -I../ -c app_rand.c
gcc -DOPENSSL_NO_PSK -DMONOLITH -I$OPENSSLDIR/include -I../ -c s_cb.c
gcc -DOPENSSL_NO_PSK -DMONOLITH -I$OPENSSLDIR/include -I../ -c s_socket.c
gcc -DOPENSSL_NO_PSK -I$OPENSSLDIR/include -I../ \
app_rand.o apps.o s_cb.o s_socket.o \
$OPENSSLDIR/lib/libssl.a $OPENSSLDIR/lib/libcrypto.a \
s_client.c -o my_s_client.exe
OPENSSL_NO_PSK
是必需的,因为声明 (psk_key
) 被注释掉了。 -I../
是必需的,因为 e_os.h
在 make install
之后没有安装。如果 OpenSSL 在发布之前真正测试了他们的东西,那肯定会很好......
然后:
$ ./my_s_client.exe -connect www.google.com:443
CONNECTED(00000003)
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com
i:/C=US/O=Google Inc/CN=Google Internet Authority G2
...
无需重建整个库或所有应用程序。不需要 openssl s_client ...
。
关于c - 如何修改s_client的代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28313713/