using Rcurl with HTTPs
I tried the following code in R on windows:
library(RCurl)
postForm("https://www.google.com/accounts/ClientLogin/",
"email" 开发者_StackOverflow社区= "me@gmail.com",
"Passwd" = "abcd",
"service" = "finance",
"source" = "Test-1"
)
but go the following error:
Error in postForm()
SL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
How do I setup RCurl to allow use of HTTPs?
just add .opts = list(ssl.verifypeer = FALSE) to your query
postForm("https://www.google.com/accounts/ClientLogin/",
"email" = "me@gmail.com",
"Passwd" = "abcd",
"service" = "finance",
"source" = "Test-1",
.opts = list(ssl.verifypeer = FALSE))
You need to install a SSL library.
For windows you can get one here: Download "OpenSSL for Windows" version 0.9.8k
Unzip to a temporary folder, and copy the files "libeay32.dll" and "ssleay32.dll" from the "bin" sub-folder to R\library\RCurl\lib\i386.
Also you might copy it into the same directory as the R.exe.
Then check if you have access to the https protocol:
library(RCurl) curlVersion()$protocol ## [1] "tftp" "ftp" "telnet" "dict" "ldap" "http" "file" "https" ## [9] "ftps" "scp" "sftp"
Then install a new set of credential files:
ca-bundle.crt can be found at : http://curl.haxx.se/ca/cacert.pem
rename / copy to ca-bundle.crt
Test with this:
getURL("https://www.google.com/accounts/ClientLogin/?service=finance&email=me@gmail.com&Passwd=abcd&source=Test-1", cainfo = "path to R/library/RCurl/CurlSSL/ca-bundle.crt")
精彩评论