我正在尝试使用curl 访问https 地址,将我的证书传递给它并使用我自己的信任库(我们有自己的CA)验证服务器的证书。我现在以 root 身份运行。
curl -v --cert /home/cdfoote/myCertificate.pem:mypassword --cacert /home/cdfoote/truststore.pem https://host.com:8444
Run Code Online (Sandbox Code Playgroud)
这给了我错误:
Unable to load client cert -8018
NSS error -8018
Run Code Online (Sandbox Code Playgroud)
谷歌搜索并确定我的curl是用nss编译的,我已将我的证书转换为.pfx(我从.jks开始)并通过以下方式将其导入到nss数据库中:
pk12util -i /home/cdfoote/myCertificate.pfx -d /etc/pki/nssdb
Run Code Online (Sandbox Code Playgroud)
当我列出数据库中的所有证书时,我看到它:
certutil -L -d /etc/pki/nssdb
Run Code Online (Sandbox Code Playgroud)
当我按昵称列出它时,我会看到它的详细信息:
certutil -L -d /etc/pki/nssdb -n myCert
Run Code Online (Sandbox Code Playgroud)
我已经通过以下方式使数据库可用:
export SSL_DIR=/etc/pki/nssdb
Run Code Online (Sandbox Code Playgroud)
现在,我正在运行的curl命令是:
curl -v --cert myCert --cacert /home/cdfoote/truststore.pem https://host.com:8444
Run Code Online (Sandbox Code Playgroud)
响应是:
About to connect to https//host.com port 8444 (#0)
Trying ipaddress
Connected to host.com (ipaddress) port 8444(#0)
Initializing NSS with certpath: sql:/etc/pki/nssdb
CAfile: /home/cdfoote/truststore.pem
CApath: none
NSS: client certificate not found: myCert
SSL connection using TLS_DHE_RSA_WITH_AES_256_CBC_SHA
Server certificate:
...
{
"status" : "403 - Forbidden",
...
Run Code Online (Sandbox Code Playgroud)
几个问题:
即使“CAfile”正确,“CApath: none”是否表示未找到信任库?如果是这样,有什么想法为什么没有找到吗?
知道为什么即使 NSS 初始化为正确的“certpath”(并且它列出得很好),也找不到“myCert”吗?
在另一个机器上,显然curl是用openssl而不是NSS编译的,上面的原始curl命令可以工作。有什么办法可以让我以这种方式运行curl而不需要重新编译它吗?
预先感谢,克雷格