编译OpenSSL支持的curl¶
在 为Pixel 4编译LineageOS 20(Android 13) 采用了自己编译的 使用OpenSSL的git ,此时系统升级安装了 OpenSSL
的 3.0.x 版本,在 Ubuntu 22.04 LTS 上默认安装的 curl
是 7.81.0
,此时和 OpenSSL
的 3.0.x 版本一起工作会出现异常 unexpected eof while reading
报错:
platform/external/rust/crates/grpcio-sys:
fatal: unable to access 'https://android.googlesource.com/platform/external/rust/crates/grpcio-sys/': OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0
platform/external/rust/crates/grpcio-sys: sleeping 4.0 seconds before retrying
fatal: unable to access 'https://android.googlesource.com/platform/external/rust/crates/grpcio-sys/': error:0A000126:SSL routines::unexpected eof while reading
error: Cannot fetch platform/external/rust/crates/grpcio-sys from https://android.googlesource.com/platform/external/rust/crates/grpcio-sys
备注
不过我还是不能确定是否真正解决了这个问题,看起来还是有同样的报错。翻墙网络不太稳定似乎也是有可能的
解决方法是重新编译支持OpenSSL 3.0.x的最新版本curl:
apt remove curl
apt purge curl
apt-get update
apt-get install -y libssl-dev autoconf libtool make
cd /usr/local/src
wget https://github.com/curl/curl/releases/download/curl-8_4_0/curl-8.4.0.tar.gz
tar xfz curl-8.4.0.tar.gz
cd curl-8.4.0
./buildconf
./configure --with-ssl
make
sudo make install
sudo cp /usr/local/bin/curl /usr/bin/curl
sudo ldconfig
curl -V
不过,此时运行curl下载https内容时候会有报错:
platform/external/rust/crates/macaddr:
/usr/lib/git-core/git-remote-https: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/lib/git-core/git-remote-https)
fatal: unable to access 'https://android.googlesource.com/platform/external/rust/crates/macaddr/': OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to android.googlesource.com:443
platform/external/rust/crates/macaddr: sleeping 4.0 seconds before retrying
这个问题参考 libcurl.so.4 no version information available
sudo ln -fs /usr/lib/libcurl.so.4 /usr/local/lib/