curl - 如何在 Ubuntu 上使用旧版 SSL 支持编译 Curl?

标签 curl ubuntu-18.04

尝试使用 Curl 连接到启用 HTTPS 的旧网站时,出现以下错误:

curl https://10.11.1.44
curl: (35) error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol

更详细地说:
* Expire in 0 ms for 6 (transfer 0x55a4192abdd0)
*   Trying 10.11.1.44...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x55a4192abdd0)
* Connected to 10.11.1.44 (10.11.1.44) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (OUT), TLS alert, protocol version (582):
* error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol
* Closing connection 0
curl: (35) error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol

如果我尝试使用 --ssl2--ssl3选项,我收到以下错误:
root@kali:~# curl https://10.11.1.44/ --sslv2
curl: (4) OpenSSL was built without SSLv2 support
root@kali:~# curl https://10.11.1.44/ --sslv3
curl: (4) OpenSSL was built without SSLv3 support

我已经查阅了以下页面,了解如何使用 SSL2/3 支持构建 Curl,但我不确定如何启用它?

https://curl.haxx.se/docs/install.html

有任何想法吗?

最佳答案

更新:curl dropped support for --sslv2 / sslv3在 curl 7.76.1 版发布后的某个时候,因此您必须确保同时编译 curl 7.76.1 版或更旧的版本。已更新说明以确保生成 curl 7.76.1。 (感谢 Matias Barros 的更新)
你需要从源代码编译 curl 和你的 ssl 后端,显然你需要一个 C 编译器,可能还有更多的东西,但不知道是什么,希望这应该涵盖它:

sudo apt-get install gcc build-essential make cmake autoconf git automake libtool
这可能可以通过多个 ssl 后端来完成,但由于我最熟悉 OpenSSL,我将继续使用 OpenSSL,以构建 openssl,请访问 openssl 存储库 https://github.com/openssl/openssl并找到一个合适的 openssl 版本,在这个例子中我选择了版本 1.1.1k (这是撰写本文时最新的稳定版 openssl 版本),
git clone -b 'OpenSSL_1_1_1k' --single-branch --depth 1 https://github.com/openssl/openssl
cd openssl
./config no-shared enable-ssl2 enable-ssl3 enable-ssl3-method
make -j $(nproc)
(最后一步可能需要一段时间)但是 openSSL 的构建脚本不会创建 lib 文件夹,但是 curl 的构建脚本期望 lib 文件位于 openssl 文件夹内的 lib 文件夹中,因此在 make 之后,运行
mkdir lib
cp *.a lib;
一旦完成,就该制作 curl 了,所以 cd ..离开那里并克隆 the last version of curl supporting the --sslv2 / --sslv3 switches 7.76.1 ,
git clone -b 'curl-7_76_1' --single-branch --depth 1 https://github.com/curl/curl.git
cd curl
./buildconf
LDFLAGS="-static" ./configure --with-ssl=$(realpath ../openssl) --disable-shared  --enable-static
make -j $(nproc)
(如果你想知道我为什么使用 realpath:curl 的构建脚本中似乎有一个错误,如果你提供相对路径,它会导致它失败,所以似乎需要绝对路径。如果你想知道为什么我做了一个静态构建,又名 - -disable-shared --enable-static,您的 $PATH 中可能有不同的 libopenssl 库,因此为了避免与 ubuntu 的内置 libopenssl 冲突,静态构建更安全。)
最后,
/temp2/curl# ./src/curl --sslv3 https://google.com
curl: (35) error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version
(因为 https://google.com 根本不再支持 sslv3。)
TL; 博士
git clone -b 'OpenSSL_1_1_1k' --single-branch --depth 1 https://github.com/openssl/openssl
cd openssl
./config no-shared enable-ssl2 enable-ssl3 enable-ssl3-method
make -j $(nproc)
mkdir lib
cp *.a lib;
cd ..
git clone -b 'curl-7_76_1' --single-branch --depth 1 https://github.com/curl/curl.git
cd curl
./buildconf
LDFLAGS="-static" ./configure --with-ssl=$(realpath ../openssl) --disable-shared  --enable-static
make -j $(nproc)
./src/curl --sslv3 https://google.com

关于curl - 如何在 Ubuntu 上使用旧版 SSL 支持编译 Curl?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56377171/

相关文章:

ssl - GET 请求 ssl_choose_client_version :unsupported protocol

curl 与 Kerberos 错误 : option --negotiate: the installed libcurl version doesn't support this

php - ffmpeg 命令通过命令行执行,而不是通过 PHP 脚本

python - urllib2 HTTPPasswordMgr 不起作用 - 凭据未发送错误

http - 发送没有 Accept header 的 curl 请求?

nginx - 如何 : stream with ffmpeg and nginx rtmp, Ubuntu

python - 如何将所有属性导入 numpy 模块?

linux - 在 Linux Mint 19 Tara 上安装 Virtualbox

php - 如何使用 curl 和 php 从另一个域获取 json 数据?

java - 如何使用 vagrant 在 ubuntu 上安装 maven 3.8 和 jdk 17