URL加载到浏览器中,但不加载到终端(curl或Node.js)

URL加载到浏览器中,但不加载到终端(curl或Node.js),node.js,xml,curl,request,ssl-certificate,Node.js,Xml,Curl,Request,Ssl Certificate,我想请求GEThttps://www.bnro.ro/nbrfxrates.xml(罗马尼亚国家银行)获取今天的汇率 虽然XML文档在浏览器中加载良好(在Safari和Chrome中进行了测试),但在终端中却以某种方式失败(使用Node.js和curl进行检查): 我尝试从Chrome中使用Copy as CURL命令选项,但这也不起作用 为什么会这样?如何修复它?缺少的证书包,请在此处阅读更多关于它的信息,但TL;DR正在下载并运行 这确实有效,但我如何在全球范围内安装它,以便其他终端工具能够

我想请求
GET
https://www.bnro.ro/nbrfxrates.xml(罗马尼亚国家银行)获取今天的汇率

虽然XML文档在浏览器中加载良好(在Safari和Chrome中进行了测试),但在终端中却以某种方式失败(使用Node.js和curl进行检查):

我尝试从Chrome中使用Copy as CURL命令选项,但这也不起作用


为什么会这样?如何修复它?

缺少的证书包,请在此处阅读更多关于它的信息,但TL;DR正在下载并运行


这确实有效,但我如何在全球范围内安装它,以便其他终端工具能够使用它(例如我的Node.js应用)?@IonicăBizău好问题,我不太确定,但如果您使用的是linux,请尝试在挖掘后将cacert.pem另存为
/etc/ssl/cert.pem
,curl将在linux系统上搜索以下位置的证书捆绑包:
/etc/ssl/certs/ca certificates.crt
/etc/pki/tls/certs/ca bundle.crt
/usr/share/ssl/certs/ca bundle.crt
/usr/local/share/certs/ca root-nss.crt
/etc/ssl/cert.pem
(来源:)-如果您使用的是windows tho,我真的不知道=/@IonicăBizău如果您的节点应用程序正在使用libcurl,那么您可以设置
curl\u easy\u setopt(ch,CURLOPT\u CAINFO,'/path/to/cacert.pem');
手动指定cacert的位置
$ curl -vL http://www.bnro.ro/nbrfxrates.xml
* Expire in 0 ms for 6 (transfer 0x7f8a5c009c00)
* Expire in 1 ms for 1 (transfer 0x7f8a5c009c00)
...
* Expire in 5 ms for 1 (transfer 0x7f8a5c009c00)
*   Trying 194.102.208.89...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x7f8a5c009c00)
* Connected to www.bnro.ro (194.102.208.89) port 80 (#0)
> GET /nbrfxrates.xml HTTP/1.1
> Host: www.bnro.ro
> User-Agent: curl/7.64.0
> Accept: */*
> 
< HTTP/1.1 302 Found
< Date: Fri, 14 Jun 2019 11:13:13 GMT
< Location: https://www.bnro.ro/nbrfxrates.xml
< Server: BigIP
< Content-Length: 0
< X-Cache: MISS from HS-F0
< X-Cache-Lookup: MISS from HS-F0:0
< Via: 1.1 HS-F0 (squid/3.4.8)
< Connection: keep-alive
< 
* Connection #0 to host www.bnro.ro left intact
* Issue another request to this URL: 'https://www.bnro.ro/nbrfxrates.xml'
* Expire in 1 ms for 1 (transfer 0x7f8a5c009c00)
* Expire in 0 ms for 1 (transfer 0x7f8a5c009c00)
...
* Expire in 1 ms for 1 (transfer 0x7f8a5c009c00)
*   Trying 194.102.208.89...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x7f8a5c009c00)
* Connected to www.bnro.ro (194.102.208.89) port 443 (#1)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /opt/local/share/curl/curl-ca-bundle.crt
  CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS alert, unknown CA (560):
* SSL certificate problem: unable to get local issuer certificate
* Closing connection 1
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
{ Error: unable to verify the first certificate
    at TLSSocket.<anonymous> (_tls_wrap.js:1104:38)
    at emitNone (events.js:105:13)
    at TLSSocket.emit (events.js:207:7)
    at TLSSocket._finishInit (_tls_wrap.js:638:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:468:38) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' }
curl -vL --cacert cacert.pem http://www.bnro.ro/nbrfxrates.xml