ssl - wget:它在哪里寻找证书?

标签 ssl openssl wget

我有一个 HTTPS 站点,需要中间证书来验证服务器 SSL 证书。

如果我将中间证书放入/etc/ssl/certs(并创建散列链接)

openssl s_client -connect IP:PORT

会起作用。否则我会收到验证错误。

wget 在哪里查找证书?如果我在 wget 中明确设置 --ca-directory,我只能让它工作。

所以 openssl 似乎会查看/etc/ssl/certs 而 wget 不会。

谢谢!

编辑

如果我用 -d 运行 wget 然后我看到没有 --ca-directory 它加载 大约150个证书。有了这个选项,它超过了 300。所以我认为它必须是另一条路径,然后是 openssl-default。

Debian 10 上的 linux-gnu 上的 Wget 1.19.4

最佳答案

根据 wget 的联机帮助页:

Without this option Wget looks for CA certificates at the system-specified locations, chosen at OpenSSL installation time.

那是哪里? Turns out, that's complicated .这取决于你的系统等。

找出wget实际做了什么的简单方法是

  1. 读取它的输出:

    Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'

  2. 使用 strace:

    strace wget https://your-url

    在输出中,您可以读取 wget 打开、尝试打开的文件等。

由于 strace 产生了相当多的输出,您可能希望将其限制为某些系统调用。看起来 wget 使用 openat 来读取文件,所以:

strace -e openat wget https://your-url

包含有趣的行:

openat(AT_FDCWD, "/usr/share/ca-certificates/trust-source/mozilla.trust.p11-kit", O_RDONLY|O_CLOEXEC) = 4
openat(AT_FDCWD, "/usr/share/ca-certificates/trust-source/anchors/CAcert.org_root.crt", O_RDONLY|O_CLOEXEC) = 4
openat(AT_FDCWD, "/usr/share/ca-certificates/trust-source/anchors/CAcert.org_class3.crt", O_RDONLY|O_CLOEXEC) = 4
openat(AT_FDCWD, "/etc/ssl/certs/ca-certificates.crt", O_RDONLY) = 3

它查看的位置甚至更多,它们甚至可能因您的系统而异。

关于ssl - wget:它在哪里寻找证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48949008/

相关文章:

c - 安装了 OpenSSL,没有 openssl.h 文件

linux - 如何使用 wget 一次下载所有这些文件?

javascript - 下载从 javascript 生成 POST 参数的主页

linux - 无法使用wget登录网站

javascript - 为什么 IE8 错误地提示加载了非安全元素?

ssl - 如何在 Play 2 框架中使用 SSL?

android - 使用 Xamarin Android 与客户端证书进行 SSL 通信

tomcat - 如何使用公钥证书客户端

ssl - 外部网站的自签名证书

openssl - SSLv2/SSLv3 读取客户端问候时出错