install.packages() 无法使用自签名 SSL 证书访问自定义 CRAN

install.packages() can't access a custom CRAN using a self signed SSL cert

我构建了一个自定义的本地 CRAN 存储库,需要通过 HTTPS 提供服务。

出于不想让您厌烦的原因,我使用的是使用 openssl 生成的自签名证书。

存储库已经构建并且可以在普通的旧 HTTP 上正常工作,但是如果我尝试使用 HTTPS,我会收到以下错误:

Warning: unable to access index for repository https://server/cran/src/contrib:
 cannot open URL 'https://server/cran/src/contrib/PACKAGES'

我可以从命令行使用 curl -k 访问 URL,但我不知道如何让它与 R 一起工作。

我要么需要告诉 R 盲目地接受任何证书,要么以某种方式告诉它 cert/key。

用于生成证书的完整命令是...

openssl -req -newkey rsa:2048 -keyout /path/to/file.key -nodes -x509 -days 365 -out /path/to/file.crt

我目前正在使用 RedHat Linux 客户端,但很快也需要从 Windows 客户端访问它。

您可以通过 options() 参数化 download.file(),这应该有助于 install.packages(),因为它使用 `download.file()。

简而言之,只要您可以与 curlwget 一起使用,您就可以将交易外包给他们。

来自help(download.file)

method: Method to be used for downloading files. Current download methods are ‘"internal"’, ‘"wininet"’ (Windows only) ‘"libcurl"’, ‘"wget"’ and ‘"curl"’, and there is a value ‘"auto"’: see ‘Details’ and ‘Note’.

该页面上还有很多内容。它应该可以满足您的需求。