我构建了一个自定义的本地 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 盲目接受任何证书,要么以某种方式告诉它这个证书/ 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()
因为它使用`下载.file()。
简而言之,只要您可以使其与 curl
或 wget
配合使用,您就可以将交易外包给他们。
来自帮助(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’.
该页面上还有更多内容。它应该可以帮助您。
关于r - install.packages() 无法使用自签名 SSL 证书访问自定义 CRAN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47558426/