我正在尝试构建一些最小的容器映像(基于systemd容器中的portablectl,它实际上使用chroot进行容器化)。我遇到了一些程序无法发出HTTPS请求的问题。演示的最简单的例子是curl,我认为修复curl会修复其他应用程序。断开似乎与卷曲,找到根证书或CA束有关。
以下命令:
sudo chroot /etc/portables/network /usr/bin/curl -Huser-agent:example/1.0 https://www.google.com/search?q=foo...results:
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.curl二进制文件是使用Ubuntu的包工具“安装”到chroot上的,我已经将我的主机环境中的/etc/ssl/certs/ca-testicates.crt中的Ubuntu根证书复制到chroot。
本质上,这就是我为chroot安装curl和其他一些与网络相关的工具(以及lib依赖项)所运行的:
apt-get -y install --reinstall \
bind9-host ca-certificates curl dnsutils \
iputils-ping \
libasn1-8-heimdal \
libbind9-161 libbsd0 libc6 libcap2 libcom-err2 libdns1104 libffi6 \
libgcc1 \
libgcrypt20 libgmp10 libgnutls30 libgpg-error0 \
libgssapi-krb5-2 libgssapi3-heimdal \
libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal \
libhogweed4 libhx509-5-heimdal \
libicu63 libidn2-0 \
libirs161 \
libisc1100 libisccfg163 \
libjson-c4 libkeyutils1 libk5crypto3 libkrb5-3 libkrb5-26-heimdal \
libkrb5support0 \
libldap-2.4-2 libldap-common liblwres161 liblzma5 libnettle6 \
libnghttp2-14 libp11-kit0 \
libpsl5 libroken18-heimdal librtmp1 \
libsasl2-2 libsqlite3-0 libssh-4 libssl1.1 \
libstdc++6 \
libtasn1-6 libunistring2 libwind0-heimdal libxml2 \
netcat-openbsd zlib1g
echo nameserver 127.0.0.53 >> /etc/resolv.conf
echo options edns0 >> /etc/resolv.conf使用curl -k选项将按预期工作;它将忽略cert错误配置,并成功地发出HTTPS请求。
此外,如果我显式地设置了--cafile /etc/ssl/certs/ca-certificates.crt,它就可以正常工作。
但是,如果我运行curl -v,我会看到以下内容:
* Trying 2607:f8b0:4007:80c::2004:443...
* TCP_NODELAY set
* Connected to www.google.com (2607:f8b0:4007:80c::2004) 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 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (OUT), TLS alert, unknown CA (560):
* SSL certificate problem: unable to get local issuer certificate所以您可以看到它有CApath /etc/ssl/certs,但是有一个空的CAfile。
发布于 2020-07-29 17:03:37
问题似乎是“如果curl是针对OpenSSL构建的,目录必须使用OpenSSL提供的c_rehash实用程序进行处理”(卷曲法)。
从本质上说,使用这个curl构建时,ca-Cericates.crt包不会被使用,除非它是在--cafile (或.curlrc中的cafile= )中显式请求的。相反,它正在寻找一个特定的目录布局,其中包含指向目标文件的散列符号链接。
因此,修复方法是将ca-Cericates.crt包分成多个文件,然后运行:
ca_rehash /etc/ssl/certshttps://stackoverflow.com/questions/63120343
复制相似问题