我在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以允许使用HTTP?
答案 0 :(得分: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))
答案 1 :(得分:11)
您需要安装SSL库。
对于Windows,您可以在这里获得一个:Download "OpenSSL for Windows" version 0.9.8k
解压缩到临时文件夹,然后复制文件“libeay32.dll”和 “ssleay32.dll”从“bin”子文件夹到R \ library \ RCurl \ lib \ i386。
您也可以将其复制到与R.exe相同的目录中。
然后检查您是否有权访问https协议:
library(RCurl)
curlVersion()$protocol
## [1] "tftp" "ftp" "telnet" "dict" "ldap" "http" "file" "https"
## [9] "ftps" "scp" "sftp"
然后安装一组新的凭据文件:
ca-bundle.crt可在以下网址找到:http://curl.haxx.se/ca/cacert.pem
重命名/复制到ca-bundle.crt
用此测试:
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")