Mark Sellors
Mark Sellors

Reputation: 23

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

I've built a custom, on-prem, CRAN repo that needs to be served over HTTPS.

For reasons I wont bore you with, I'm using a self signed certificate generated with openssl.

The repo has been built and works fine over plain-old HTTP, but if I try to use HTTPS, i get the following error:

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

I can access the URL with curl -k from the command line, but I can't figure out how to make it work with R.

I either need to tell R to blindly accept any certs, or somehow tell it about this cert/key.

the full command used to generate the cert was...

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

I'm working on a RedHat Linux client at the moment, but it'll need to be accessible from Windows clients shortly too.

Upvotes: 2

Views: 918

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368231

You can parameterize download.file() via options(), and that should help with install.packages() as it uses `download.file().

In short, for as long as you can make it work with curl or wget you can farm the transaction out to them.

From 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’.

There is a lot more on that page. It should get you covered.

Upvotes: 3

Related Questions