开发者

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.

  1. For windows you can get one here: Download "OpenSSL for Windows" version 0.9.8k

  2. 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.

  3. Also you might copy it into the same directory as the R.exe.

  4. 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"  
    
  5. 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

  6. 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")
    
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜