cURL SSL连接错误35,NSS错误-5961 [英] cURL SSL connect error 35 with NSS error -5961

查看:2436
本文介绍了cURL SSL连接错误35,NSS错误-5961的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个远程Windows 7服务器,该服务器只能通过端口768上的HTTPS访问。该服务器使用的是来自本地CentOS服务器中列出的CA的签名证书。



每当我尝试使用以下命令通过cURL访问远程服务器时,都会出现以下错误:

  [usr @ serv certs]#curl -3 -v https://1.1.1.1:768/user/login 
*关于connect()到1.1.1.1端口768(#0)
*正在尝试1.1。 1.1 ...已连接
*已连接至1.1.1.1(1.1.1.1)端口768(#0)
*使用证书路径初始化NSS:sql:/ etc / pki / nssdb
* CAfile :/etc/pki/tls/certs/ca-bundle.crt
CApath:无
* NSS错误-5961
*关闭连接#0
* SSL连接错误
curl:(35)SSL连接错误

(请注意,IP地址已被隐藏以确保安全性原因)。



我正在运行以下版本的cURL:

  curl 7.19.7(x86_64-redhat-linux-gnu)libcurl / 7.19.7 NSS / 3.14.0.0 zlib / 1.2.3 libidn / 1.18 libssh2 / 1.4.2 

可以在其他两个都运行Windows XP而不是Windows 7的远程服务器上运行。



我尝试强制cURL使用SSLv3(使用-3标志和-SSLv3标志)没有成功。






我刚刚在运行Raspbian的Raspberry Pi上测试了相同的CURL命令,能够成功连接。因此,我相信这可能与CentOS服务器上使用的cURL版本有关。树莓派正在运行以下版本:

  curl 7.26.0(arm-unknown-linux-gnueabihf)libcurl / 7.26。 0 OpenSSL / 1.0.1e zlib / 1.2.7 libidn / 1.25 libssh2 / 1.4.2 librtmp / 2.3 
协议:dict文件ftp ftps gopher http https imap imaps ldap pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
功能:调试GSS协商IDN IPv6大文件NTLM NTLM_WB SSL libz TLS-SRP


解决方案带有NSS的

curl 默认情况下从 / etc / pki / tls / certs / ca-bundle读取根CA证书.crt 以PEM格式。

  *使用证书路径初始化NSS:sql:/ etc / pki / nssdb 
* CAfile:/etc/pki/tls/certs/ca-bundle.crt

您可以通过curl的选项<$ c $指定另一个(您的)CA证书(或 NSS共享数据库上的捆绑包)。 c>-cacert 和包含CA证书的PEM文件。



如果不使用-cacert 选项手动指定证书,NSS将尝试从中选择合适的证书NSS数据库(位于 / etc / pki / nssdb )。您可以通过curl的选项-cert 指定其昵称,如果密钥已嵌入证书中,则绰号就足够了;否则,您可以使用证书密钥指定PEM文件使用-键。如果密钥受密码保护,则可以通过curl的选项-pass 来提供密钥,以便可以使用 nss-tools yum install nss-tools ) p>

添加证书(公共命令行)

  certutil -d sql:/ etc / pki / nssdb -A -t< TRUSTARGS> -n<证书昵称> -i<证书文件名> 

关于受托人



指定信任属性在现有证书中进行修改或在创建证书或将其添加到数据库时应用证书。


有三种可用的信任类别对于每个证书,
以此顺序表示: SSL,电子邮件,对象签名。在每个
类别位置中,使用零个或多个以下属性代码:




  • p禁止(明确不信任)

  • P受信任的对等方

  • c有效的CA

  • T受信任的CA颁发客户端证书(暗示c)

  • C受信任的CA颁发服务器证书(仅SSL)(表示c)

  • u证书可用于身份验证或签名

  • w发送警告(在该上下文中使用证书时与其他属性结合使用以包含警告)



属性代码类别之间用逗号隔开,
则用引号将整个属性集括起来。例如:



-t TCu,Cu,Tuw


信任用于颁发SSL服务器证书的根CA证书

  certutil -d sql:/ etc / pki / nssdb -A -t C, -n<证书昵称> -i<证书文件名> 

导入中间CA证书

  certutil -d sql:/ etc / pki / nssdb -A -t, -n<证书昵称> -i<证书文件名> 

信任自签名服务器证书

  certutil -d sql:/ etc / pki / nssdb -A -t P, -n<证书昵称> -i<证书文件名> 

为SSL客户端身份验证添加个人证书和私钥

  pk12util -d sql:/ etc / pki / nssdb -i PKCS12_file_with_your_cert.p12 

列出存储在NSS DB中的所有证书

  certutil -d sql:/ etc / pki / nssdb -L ​​

证书的清单详细信息

  certutil -d sql:/ etc / pki / nssdb -L ​​-n<证书昵称> 

删除证书

  certutil -d sql:/ etc / pki / nssdb -D -n<证书昵称> 

希望这会有所帮助。


I have a remote Windows 7 server that is accessible only via HTTPS on port 768. The server is using a signed certificate from a CA listed in the local CentOS server.

Whenever I try to access the remote server via cURL using the following command, it errors out as follows:

[usr@serv certs]# curl -3 -v https://1.1.1.1:768/user/login
* About to connect() to 1.1.1.1 port 768 (#0)
*   Trying 1.1.1.1... connected
* Connected to 1.1.1.1 (1.1.1.1) port 768 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* NSS error -5961
* Closing connection #0
* SSL connect error
curl: (35) SSL connect error

(Note that the IP address has been hidden for security reasons).

I am running the following version of cURL:

curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2

It's worth noting that this is working on two other remote servers which are both running Windows XP rather than windows 7.

I have tried forcing cURL to use SSLv3 (using the -3 flag and the -SSLv3 flag) with no success.


I have just tested the same CURL command on a Raspberry Pi running Raspbian and have been able to connect successfully. I therefore believe it may be an issue with the version of cURL in use on the CentOS server. The raspberry pi is running the following version:

curl 7.26.0 (arm-unknown-linux-gnueabihf) libcurl/7.26.0 OpenSSL/1.0.1e zlib/1.2.7 libidn/1.25 libssh2/1.4.2 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: Debug GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP

解决方案

curl with NSS read the Root CA certificates by default from "/etc/pki/tls/certs/ca-bundle.crt" in the PEM format.

* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt

You can specify another (your) CA certificate (or bundle on the NSS Shared DB) by curl's option --cacert with the PEM file containing the CA certificate(s).

If you don't specify the certificate manually with --cacert option, NSS tries to select the right one from the NSS database (located at /etc/pki/nssdb) automatically. You can specify it's nickname by curl's option --cert, this should be sufficient if the key is embedded in the cert, if not you can specify the PEM file with the certificate key using the --key. If the key is protected by a pass-phrase, you can give it by curl's option --pass so you can import your certificate to the NSS shared DB using the nss-tools (yum install nss-tools)

Adding a certificate (common command line)

certutil -d sql:/etc/pki/nssdb -A -t <TRUSTARGS> -n <certificate nickname> -i <certificate filename>

About TRUSTARGS

Specify the trust attributes to modify in an existing certificate or to apply to a certificate when creating it or adding it to a database.

There are three available trust categories for each certificate, expressed in this order: " SSL , email , object signing ". In each category position use zero or more of the following attribute codes:

  • p prohibited (explicitly distrusted)
  • P Trusted peer
  • c Valid CA
  • T Trusted CA to issue client certificates (implies c)
  • C Trusted CA to issue server certificates (SSL only) (implies c)
  • u Certificate can be used for authentication or signing
  • w Send warning (use with other attributes to include a warning when the certificate is used in that context)

The attribute codes for the categories are separated by commas, and the entire set of attributes enclosed by quotation marks. For example:

-t "TCu,Cu,Tuw"

Trusting a root CA certificate for issuing SSL server certificates

certutil -d sql:/etc/pki/nssdb -A -t "C,," -n <certificate nickname> -i <certificate filename> 

Importing an intermediate CA certificate

certutil -d sql:/etc/pki/nssdb -A -t ",," -n <certificate nickname> -i <certificate filename>

Trusting a self-signed server certificate

certutil -d sql:/etc/pki/nssdb -A -t "P,," -n <certificate nickname> -i <certificate filename> 

Adding a personal certificate and private key for SSL client authentication

pk12util -d sql:/etc/pki/nssdb -i PKCS12_file_with_your_cert.p12

Listing all the certificates stored into NSS DB

certutil -d sql:/etc/pki/nssdb -L

Listing details of a certificate

certutil -d sql:/etc/pki/nssdb -L -n <certificate nickname>

Deleting a certificate

certutil -d sql:/etc/pki/nssdb -D -n <certificate nickname>

Hope this helps.

这篇关于cURL SSL连接错误35,NSS错误-5961的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆