理解卷曲实现

时间:2017-05-19 12:22:49

标签: ssl curl https

我无法将文档说明付诸实践。我正在尝试使用证书对Vault服务进行身份验证。 documentation说:

  

通过API

     

登录的端点是/ login。客户只需连接即可   他们的TLS证书和登录端点被击中时,身份验证   后端将确定是否有匹配的可信证书   验证客户端。或者,您可以指定一个   证书角色进行身份验证。

$ curl --cacert ca.pem --cert cert.pem --key key.pem -d name=web \
     $VAULT_ADDR/v1/auth/cert/login -XPOST

现在,我要验证的节点IP:端口是17.2.24.13:8200

以下是我在远程服务器上所做的事情。

openssl s_client -showcerts -connect 17.2.24.13:8200

这会导致一个巨大的输出,其中包含一个::

部分
-----BEGIN CERTIFICATE-----
XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXX
-----END CERTIFICATE-----

现在我相信这是Vault需要的证书。

所以我把上面的输出写到vault.cer文件

现在使用vault.cer我要进行身份验证。所以我运行以下命令。

curl  --cert vault.crt  https://17.2.24.13:8200/v1/auth/cert/login -XPOST

但我得到的错误是:

curl: (60) Certificate key usage inadequate for attempted operation.
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

如果我添加-k标志,我会收到以下错误。

# curl -k  --cert vault.crt  https://17.2.24.13:8200/v1/auth/cert/login -XPOST
{"errors":["client certificate must be supplied"]}

所以我真的很困惑这个场景中我真正缺少的是什么。

2 个答案:

答案 0 :(得分:1)

openssl s_client -showcerts -connect 17.2.24.13:8200输出中显示的证书是服务器证书,而不是客户端证书。前者用于向客户端验证服务器。您正在寻求将服务器的客户端验证到您需要提供服务器信任且您拥有公钥和私钥的证书。

服务器信任哪些客户端证书以及如何获取此类证书是您应该向服务所有者提出的问题。

答案 1 :(得分:0)

通过以下命令获得的证书是Web服务器的公钥。

openssl s_client -showcerts -connect 17.2.24.13:8200

在下面的引文中"他们的TLS证书"是指客户端(curl)将向服务器提供的证书。

  

客户端只需连接其TLS证书

即可

您需要的是已签名的私钥。我在@Paul Kehrer找到了这个问题的答案" How to create .pem files for https web server"提供了有关如何生成自签名证书的一系列良好步骤。如果您需要由CA签名,您只需将CSR发送给CA进行签名。

相关问题