为什么 curl 到 https 不起作用

ITF*_*Fun 5 https curl

我可以毫无问题地执行以下操作:

curl -u "username:password" http://www.example.com/exportfile.xml
Run Code Online (Sandbox Code Playgroud)

但是如果我尝试对我们网站的 https 版本使用相同的命令,它就会失败

curl -u "username:password" https://www.example.com/exportfile.xml
Run Code Online (Sandbox Code Playgroud)

这是错误消息的样子:

About to connect() to www.example.com port 443 (#0)
Trying "some ip"... connected
Connected to www.example.com (some ip) port 443 (#0)
Initializing NSS with certpath: sql:/etc/pki/nssdb
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
NSS error -5938
Closing connection #0
SSL connect error
curl: (35) SSL connect error
Run Code Online (Sandbox Code Playgroud)

感谢所有帮助

rub*_*ils 4

尝试使用该-k/--insecure参数。

从手册页:

(SSL) 此选项明确允许curl 执行“不安全”的SSL 连接和传输。尝试使用默认安装的 CA 证书包来确保所有 SSL 连接的安全。这使得所有被认为“不安全”的连接失败,除非-k, --insecure使用。

$ curl -sku "username:password" "https://www.example.com/exportfile.xml"
Run Code Online (Sandbox Code Playgroud)

我也总是更喜欢使用该-s/--silent参数,除非我正在下载某些内容并想查看统计信息。

另请注意,使用该-s参数并不会阻止使用该-v参数时的详细输出。