【问题标题】:How to compile curl with latest openssl如何使用最新的 openssl 编译 curl
【发布时间】:2015-02-10 07:39:04
【问题描述】:

我下载curl7.40源码,已经编译openssl 1.0.2源码,现在想用openssl 1.0.2编译curl。

./configure --prefix=/usr/local/curl-7.40.0 --with-ssl 
--with-libssl-prefix=/usr/local/openssl-1.0.2

make && make install

安装后,我 ldd curl 库但仍与系统默认库链接。 ldd libcurl.so linux-vdso.so.1 => (0x00007fff2db2e000) libidn.so.11 => /usr/lib/x86_64-linux-gnu/libidn.so.11 (0x00007fafb9b6e000) librtmp.so.0 => /usr/lib/x86_64-linux-gnu/librtmp.so.0 (0x00007fafb9954000) libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007fafb96f5000) libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007fafb931b000) ...

更新
经过一番搜索,我使用以下命令进行配置。

./configure --prefix=/usr/local/curl-7.40.0 --with-ssl=/usr/local/openssl-1.0.2

但是当 make install 时,它会显示以下错误信息。

../lib/.libs/libcurl.so: undefined reference to `SSLv2_client_method'
collect2: error: ld returned 1 exit status

【问题讨论】:

  • 从 openssl 1.0.2 中删除了 SSLv2 支持。您可能包含来自一个 SSL 版本的内容和来自另一个版本的库。查看编译日志。有类似-I/usr/local/openssl-1.0.2/include 的东西吗?
  • 是的,openssl 删除了 sslv2 支持,但似乎 libcurl 仍在使用它。并从一些搜索结果中建议将 libcurl 源代码 lib/ssluse.c 修改为 cmets,但在 7.40 中,我没有找到此文件。
  • libcurl 知道在配置阶段检测 openssl 是否支持 sslv2。查看 config.log 和/或 config.h。
  • 在 config.log 中,我找到了以下信息,配置:21938:检查 SSLv2_client_method 配置:21938:gcc -o conftest -O2 -Wno-system-headers -I/usr/local/openssl- 1.0.2/include -L/usr/local/openssl-1.0.2/lib conftest.c -lssl -lcrypto -lssl -lcrypto -llber -lldap -lz >&5 配置:21938:$? = 0 配置:21938:结果:是
  • 看起来这是一个需要code changecurl 错误;从那个提交来看,curl-7.47.1 和更高版本应该可以干净地编译。

标签: c linux curl openssl


【解决方案1】:

问题可能与您构建 OpenSSL 库的方式有关。

很可能您已经构建了禁用 SSLv2 的 openssl,因为某些发行版默认禁用 SSLv2。在编译 OpenSSL 时查看系统的 ./config,并找到控制 OPENSSL_NO_SSL2 预处理器标志的选项。
为了在从源代码制作时使用正确版本的 openssl,您可以像这样制作 openssl:

cd <path-to-openssl-dir>
./config enable-ssl2 enable-ssl3 --prefix=<path-to-openssl-install-dir>

然后,您可以通过以下方式将您的 curl 版本正确链接到 openssl:

./configure --with-ssl=<path-to-openssl-install-dir>

【讨论】:

    【解决方案2】:

    SSLv2_client_method() 用于 lib/vtls/openssl.c 的第 1575 行,并带有 check,以便通过 autoconf 使用此功能。在我看来,autoconf 的 AC_CHECK_FUNCS 错误地发现您的系统安装 openssl 之前启用了 SSLv2 #includeing 您自己安装的 openssl-1.0.2 没有 SSLv2_client_method(),因此假定该功能可用。

    尝试将CFLAGS=-I/usr/local/openssl-1.0.2/include 甚至"CFLAGS=-I/usr/local/openssl-1.0.2/include -DOPENSSL_NO_SSL2" 作为参数传递给./configure,以强制openssl.c 在没有SSLv2_client_method() 被错误地假定为可用的情况下进行操作。

    【讨论】:

      猜你喜欢
      • 2016-10-10
      • 2012-08-09
      • 1970-01-01
      • 2018-04-09
      • 2017-05-13
      • 2019-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多