NSS: client certificate not found (nickname not specified)

NSS: client certificate not found (nickname not specified)报错排查及解决

curl: (35) NSS: client certificate not found (nickname not specified)

排查好久,这里记录下这个坑。

初始

这是第三方的一个接口,测试联调时,curl https://xxx.com.cn发现提示证书未信任,

curl: (60) Peer's certificate issuer has been marked as not trusted by the user.
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.

看到熟悉的报错,我知道将对方自签名证书的CA加入信任即可。一通操作之后却还是不行,但是报错变成了新的.

curl: (35) NSS: client certificate not found (nickname not specified)

-vvv也还是没发现什么新的有用信息。
curl -vvv https://xxxxx 时总是报错

* About to connect() to xxx.com.cn port 8912 (#0)
*   Trying 111.122.224.223...
* Connected to gwtest.ccic-net.com.cn (111.122.224.223) port 8912 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS: client certificate not found (nickname not specified)
* NSS error -12227 (SSL_ERROR_HANDSHAKE_FAILURE_ALERT)
* SSL peer was unable to negotiate an acceptable set of security parameters.
* Closing connection 0
curl: (35) NSS: client certificate not found (nickname not specified)

原因

其实报错提示很明显,client certificate not found,开始没想到是双向认证,一直以为是CA根证书信任没弄好,结果一直无法解决。

解决

找第三方拿到客户端证书jks证书(p12)。

openssl pkcs12 -in xxx.p12 -out client.pem -nokeys       #客户端个人证书的公钥
openssl pkcs12 -in xxx.p12 -out key.pem -nocerts -nodes     #客户端个人证书的私钥
也可以转换为公钥与私钥合二为一的文件;
openssl pkcs12 -in xxx.p12 -out all.pem -nodes                                   #客户端公钥与私钥,一起存在all.pem中

使用client.pem+key.pem

curl --cert client.pem --key key.pem https://www.xxxx.com

或使用all.pem

curl --cert all.pem  https://www.xxxx.com

问题解决~

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MicePro

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值