9

我在 Windows 上的 R 中尝试了以下代码:

library(RCurl)
postForm("https://www.google.com/accounts/ClientLogin/",
    "email" = "me@gmail.com",
    "Passwd" = "abcd",
    "service" = "finance",
    "source" = "Test-1"
)

但出现以下错误:

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

如何设置 RCurl 以允许使用 HTTPS?

4

2 回答 2

13

只需将 .opts = list(ssl.verifypeer = FALSE) 添加到您的查询中

postForm("https://www.google.com/accounts/ClientLogin/",
    "email" = "me@gmail.com",
    "Passwd" = "abcd",
    "service" = "finance",
    "source" = "Test-1",
    .opts = list(ssl.verifypeer = FALSE))
于 2013-05-24T14:45:47.477 回答
12

您需要安装 SSL 库。

  1. 对于 Windows,您可以在此处获得:下载“OpenSSL for Windows”版本 0.9.8k

  2. 解压到一个临时文件夹,将“bin”子文件夹中的“libeay32.dll”和“ssleay32.dll”文件复制到R\library\RCurl\lib\i386。

  3. 您也可以将其复制到与 R.exe 相同的目录中。

  4. 然后检查您是否可以访问 https 协议:

    library(RCurl)
    curlVersion()$protocol 
    ## [1] "tftp"   "ftp"    "telnet" "dict"   "ldap"   "http"   "file"   "https"     
    ## [9] "ftps"   "scp"    "sftp"  
    
  5. 然后安装一组新的凭证文件:

    ca-bundle.crt 可以在以下位置找到:http ://curl.haxx.se/ca/cacert.pem

    重命名/复制到 ca-bundle.crt

  6. 用这个测试:

    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")
    
于 2011-11-25T11:47:11.947 回答