undefined reference to `SSL_get1_peer_certificate‘解决方法

Posted 今天也要努力搬砖

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了undefined reference to `SSL_get1_peer_certificate‘解决方法相关的知识,希望对你有一定的参考价值。

问题:

[100%] Linking C executable example_ssl_serv
CMakeFiles/example_ssl_serv.dir/example_ssl_serv.c.o: In function `main':
example_ssl_serv.c:(.text+0x49e): undefined reference to `SSL_get1_peer_certificate'
collect2: error: ld returned 1 exit status
CMakeFiles/example_ssl_serv.dir/build.make:94: recipe for target 'example_ssl_serv' failed
make[2]: *** [example_ssl_serv] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/example_ssl_serv.dir/all' failed
make[1]: *** [CMakeFiles/example_ssl_serv.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
root@cd2e1925ffbe:/work/CyberSecurityCode/sslservexample# ^C

原因:

        SSL_get1_peer_certificate源码里调用的是SSL_get_peer_certificate,而报错的是SSL_get1_peer_certificate这个函数,所以问题应该出现在库里面而不是源码里面。具体原因不太确定,感觉和某个编译选项有关

解决方法 :

        执行以下命令重新编译安装

       

 cd /work/download/openssl-1.1.1o/
./config --prefix=/usr/local --openssldir=/etc/ssl --libdir=lib enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers -DOPENSSL_NO_GOST zlib shared
make
make install
ln -s /usr/local/bin/openssl /usr/bin/openssl
ln -s /usr/local/include/openssl/ /usr/include/openssl
echo "/usr/local/lib/" >> /etc/ld.so.conf
ldconfig

参考:openssl: symbol EVP_mdc2 version OPENSSL_1_1_0_x-ghost的博客-CSDN博客

以上是关于undefined reference to `SSL_get1_peer_certificate‘解决方法的主要内容,如果未能解决你的问题,请参考以下文章

lib1funcs.S(用于解决裸板实现 printf 中的问题: undefined reference to `__aeabi_uidivmod' 和 undefined referenc

eclipse 报错:93: undefined reference to

undefined reference to异常怎么解决

undefined reference to xxx

undefined reference to异常怎么解决

ubuntu下调试ffmpeg程序出现undefined reference to pthread_once ,undefined reference to uncompress错误