网页在浏览器中有效,但在 R 中无效:SSL 证书问题:证书已过期

Webpage works in browser, but not from R: SSL certificate problem: certificate has expired

This url 在浏览器中工作,提供一些 JSON 数据。

它从 R 开始工作直到最近,现在 returns:

library(jsonlite)
fromJSON("https://api.worldbank.org/v2/country?format=json")

# Error in open.connection(con, "rb") : 
#   SSL certificate problem: certificate has expired

library(rvest)
read_html("https://api.worldbank.org/v2/country?format=json")

# Error in open.connection(con, "rb") : 
#   SSL certificate problem: certificate has expired

到目前为止我所知道的

我不确定这是 API 方面的问题,还是 R 中某处的问题?

对于遇到类似问题的其他人

原因

网站所有者的 SSL 证书已过期。

我能够通过 this 网站确认这一点:

(不完美)解决方案

由于我无法控制 url 的 SSL 证书,我只是将我使用的所有 url 从 https 更改为 http

例如:

"https://api.worldbank.org/v2/country?format=json"

更改为

"http://api.worldbank.org/v2/country?format=json"

其实我也有这个问题...无论哪种方式我都无法访问它。我收到以下错误消息(WDIcache() 当然也不起作用)

Error in file(con, "r") : cannot open the connection to 'http://api.worldbank.org/indicators?per_page=25000&format=json'