Solved: SSL: certificate verification failed with R and twitteR

0

Have you been trying to use R and hook it up with something like twitteR and got an SSL error message?

Me too. But I found the problem. Here was my original code:

> cred$handshake(cainfo="cacert.pem") 

But I kept getting the following error:

Error in function (type, msg, asError = TRUE)  : 
SSL: certificate verification failed (result: 5)

The fix was simple. Change this code:

> cred$handshake(cainfo="cacert.pem") 

To the following code (make sure you are directing the .pem location correctly. Mine is at the root of my Mac yours could be in /User/username/Documents/cacert.pem for example):

> cred$handshake(cainfo=system.file("CurlSSL", "cacert.pem", package = "RCurl"))

Then your browser window will pop open and ask for your Twitter OAuth PIN. Put that in and you are all set. Don’t forget to save your work and test for TRUE with registerTwitterOAuth line:

> save(cred, file="twitter authentication.Rdata")
> registerTwitterOAuth(cred)

LEAVE A REPLY