R: downloading error 'SSL peer certificate or SSH remote key was not OK'

Viewed 817

I want to download a png file from a website and the code worked for me before. However, now it keeps showing an error as follows. Can you please help me with this? Thanks heaps.

url1 ="https://niwa.co.nz/static/climate/smd_anom.png?1234"
filename1 <-paste("NiwaSoil_", format(Sys.Date()-1 , "%Y_%m_%d"), ".png",sep="")
download.file(url1,filename1, mode = 'wb'

The error: enter image description here

3 Answers

I installed R 4.2.0 today so the problem caused by this new version of R. I reinstalled R to the other version 4.1.2 and my code is now working fine.

I had a similar problem after upgrading to R 4.2 on a computer without internet access using a custom CRAN mirror with a custom certificate. The solution from this SO answer worked for me, but I think it should be used with care on the internet.

If you decide to use R 4.2.0, you need to install new Rtools for this version since the previous Rtools wont work with R.4.2.0

Related