Twitter, Roauth and Windows: Register Ok, But Certificate Verify Failed

TwitteR, ROAuth and Windows: register OK, but certificate verify failed

Try:

getUser("Rbloggers")$followersCount
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
getUser("Rbloggers",cainfo="cacert.pem")$followersCount
[1] 2752

Every get/update action needs a cainfo="cacert.pem" append behind. That annoy.

ROauth on Windows using R

UPDATE MAY 2013

Seeing as I keep seeing people mention these issues on Windows, if you do the following before running your R script, it should solve the issue automatically without you needing to do anything else in this post:

library(RCurl) 
options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))

This will set the option gloabally and will be used in all RCurl calls.

I'll leave the rest of the post below for reference.


NOTE: This isn't a direct solution, but it's also too long for a comment or an #rstats tweet...

Reading the output, the problem seems to be with cURL (and hence package RCurl). I can recreate the same error for a different application which happens to me on Windows 7 x64 Pro with R2.14.0 using RCurl_1.6-10:

library(RCurl)
u <- "https://raw.github.com/tonybreyal/Blog-Reference-Functions/master/R/bingSearchXScraper/bingSearchXScraper."
x <- getURL(u)
#Error in curlPerform(curl = curl, .opts = opts, .encoding = .encoding) :
# SSL certificate problem, verify that the CA cert is OK. Details:
#error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

The error code is the same. In your case it means that Twitter is sending you a certificate to tell you that they are the real Twitter website. But how do you know that they are telling the truth? Somewhere on your system you need to have a file which can confirm it, obtained from a trusted source.

One solution is to get that file as follows which solves the issue (note, there are other websites which provide such files, I've used the official cURL website):

download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
x <- getURL(u, cainfo = "cacert.pem")

I've not looked at the internals of ROAuth (anything written in S3/S4/Reference-classes scares the hell out of me) but at some point it would need to set the cainfo parameter to overcome this issue (on Windows that is - seems to work fine on Ubuntu for my example above). I don't know if ROAuth lets the user add these curl parameters somehow but that would be the way to go to solve it.

Hope that helps a little.

Tony Breyal

P.S. another method is possible, and avoids downloading the certificate from cURL, but is not recommended for the type of thing you're doing (seriously, for your purpose of using twitter, I would recommend against this big time):

x <- getURL(u, ssl.verifypeer = FALSE)

UPDATE 2011:

This seems to work across platforms (well, Ubuntu and Windows at any rate) and does not require you to directly download the SSL certs as RCurl comes with them already:

 x <- getURL(u, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))


Related Topics



Leave a reply



Submit