RGoogleTrends:SSL证书问题,验证CA证书是否正常

时间:2013-04-30 07:45:03

标签: r ssl-certificate rcurl

在继续操作之前,请下载RGoogleTrends_0.2-1.tar.gz here,这是Duncan Temple Lang的网站。

可重复的例子(或者,至少,我希望 可由某人重现):

op <- par(no.readonly = TRUE)
Sys.setenv(TZ = 'UTC')

# In the command line below please insert the path of your RGoogleTrends package

install.packages('C:/.../RGoogleTrends_0.2-1.tar.gz', repos = NULL, type = 'source')
install.packages('DBI')
install.packages('quantmod')
install.packages('RCurl')
install.packages('RSQLite')

require(DBI)
require(RCurl)
require(RGoogleTrends)
require(RSQLite)

我使用以下参数创建了一个Google帐户:

login = cicciopafolr@gmail.com
password = econfol1

然后是RGoogleTrends代码:

# The example below comes from RGoogleTrends package.
## Not run: 
# Picks up c(login = password) from GooglePassword option
# i.e. set with
options(GooglePassword = c(cicciopafolr = 'econfol1'))
g = googleSignIn()
ans = getGTrends("coupon", curl = g)
## End(Not run)

代码结果:

> g = googleSignIn()
Error in function (type, msg, asError = TRUE)  : 
  SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

我的sessionInfo()

> sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] parallel  stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] RSQLite_0.11.3        RCurl_1.95-4.1        bitops_1.0-5          quantmod_0.4-0       
 [5] TTR_0.21-1            Defaults_1.1-1        DBI_0.2-6             RGoogleTrends_0.2-1  
 [9] Matrix_1.0-11         lattice_0.20-13       MASS_7.3-23           truncnorm_1.0-6      
[13] numDeriv_2012.9-1     xts_0.9-3             zoo_1.7-9             RcppArmadillo_0.3.6.3
[17] Rcpp_0.10.2           rcom_2.2-5            rscproxy_2.0-5       

loaded via a namespace (and not attached):
[1] grid_2.15.2  tools_2.15.2

1 个答案:

答案 0 :(得分:-1)

我无法重现你的例子。调用getGTrends会引发错误,但不会与SSL关联。您可以在运行代码之前尝试运行以下命令:

opts <- list(
  capath = system.file("CurlSSL", "cacert.pem", package = "RCurl"));
options(RCurlOptions = opts)

如果这不能解决您的问题,请尝试以下操作:

opts <- list(
  capath = system.file("CurlSSL", "cacert.pem", package = "RCurl"), 
  ssl.verifypeer = FALSE);
options(RCurlOptions = opts)

如果其中任何一个工作,那么您可能遇到http://www.omegahat.org/RCurl/FAQ.html中描述的问题(在页面上搜索“当我尝试通过https与URL进行交互时,我收到表单错误”)。 请注意该页面有关使用ssl.verifypeer = FALSE

的危险性的警告

顺便说一句,似乎维护在https://github.com/omegahat/RGoogleTrends的软件包的版本最近更新了,而不是您提供的存储库版本。