karthik / rDrop

Programmatic interface to Dropbox
65 stars 17 forks source link

SSL Error #4

Open jknowles opened 12 years ago

jknowles commented 12 years ago

After running:

install_github( 'ROAuth', 'duncantl' )

install_github( 'rDrop' , 'karthikram' )

library( rDrop )

dropbox_credentials<-dropbox_auth( mykey, mysecret )

The following error is returned:

"Error in function (type,msg,asError=TRUE) :

SSL certificate problem, Verify that the CA cert is OK. Details: error: 14090086:SSL routine: SSL3_GET_SERVER_CERTIFICATE:certificate verify failed"

This is on a Windows 7 machine running R 2.15.1

Could the error be because the app being authorized only has access to one folder in the Dropbox, and not the full Dropbox?

karthik commented 12 years ago

I haven't encountered that issue before (one folder versus full). But I'll try to replicate the issue. Do mykey and mysecret actually return your correct keys? Did your default browser load and go to Dropbox for authorization? Were you able to ok that step?

jknowles commented 12 years ago

The keys are correct. I checked them several times before posting... was worried about that!

The browser did not load, the error was just returned before any other activity occurred.

duncantl commented 12 years ago

If you can slide curl options into the request, add

.opts = list(ssl.verify = FALSE)

and that hopefully bypass the problem, albeit unsafely.

Alternatively, you can tell curl to where to find certificates, e.g. .opts = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))

D.

On 10/9/12 1:27 PM, Jared Knowles wrote:

The keys are correct. I checked them several times before posting... was worried about that!

The browser did not load, the error was just returned before any other activity occurred.

— Reply to this email directly or view it on GitHub https://github.com/karthikram/rDrop/issues/4#issuecomment-9278070.

jknowles commented 12 years ago

That didn't seem to work. But, I did get it to work in Ubuntu without the above code.

I think I need to check out my Win 7 RCurl installation and get back with you.

jknowles commented 12 years ago

Update:

I ran the following code to no avail:


dropbox_credentials<-dropbox_auth(mykey,mysecret,
.opts=list(cainfo=system.file("CurlSSL","cacert.pem",package="RCurl")))

# Alternate

dropbox_credentials<-dropbox_auth(mykey,mysecret,
.opts=list(cainfo="Path/To/My/cacer.pem"))

# Alternate 2
a<-curlSetOpt(.opts=list(cainfo=system.file("CurlSSL","cacert.pem",package="RCurl"))
dropbox_credentials<-dropbox_auth(mykey,mysecret,.opts=a)

No luck with any of them, still getting the same SSL error.

Trying to bypass the problem didn't work either. I am wondering what the issue might be with the certificates could be.

I really love what you can do with this package and want to write a package that utilizes this access to Dropbox, but I have to figure out how to make it work on Windows installs. I checked out my own install and didn't find anything abnormal--the certificates are right there.

Any thoughts? Otherwise, perhaps I need to go check in with the RCurl folks.

karthik commented 12 years ago

Duncan (the other author for this package) is the person who also wrote RCurl. Neither of us work in a windows environment but I'll wait and see if Duncan has a response to this.

jknowles commented 12 years ago

Windows is a pain to support, I understand! But, it would be great if I could figure out what knobs to turn to get it working so I can support the bulk of the users of the package I am working on who will be Windows users.

Some further digging today turned up this question on SO:

http://stackoverflow.com/questions/6736895/using-rcurl-with-https

But, I think RCurl already has the lib built in these days.

duncantl commented 12 years ago

We can get this to work.

I assume that the version of RCurl that you have on windows does have https support (checked via the code as on the StackO post), and therefore that this is not the problem. If you don't have https, then that is the first problem.

But I suspect the problem is with the certificates. And we need to determine where in the negotiation process the complaint is arising. Can you add show us the output of

f = system.file("CurlSSL","cacert.pem",package="RCurl") f

and

file.exists(f)

Then, can you use

.opts=list(cainfo=system.file("CurlSSL","cacert.pem",package="RCurl")), verbose = TRUE)

and send the output.

Thanks D.

On 10/10/12 2:02 PM, Jared Knowles wrote:

Windows is a pain to support, I understand! But, it would be great if I could figure out what knobs to turn to get it working so I can support the bulk of the users of the package I am working on who will be Windows users.

Some further digging today turned up this question on SO:

http://stackoverflow.com/questions/6736895/using-rcurl-with-https

But, I think RCurl already has the lib built in these days.

— Reply to this email directly or view it on GitHub https://github.com/karthikram/rDrop/issues/4#issuecomment-9319468.

jknowles commented 12 years ago

Thanks for the persistence and the help. I am going to try it on another Windows box too, just in case. On this machine, when I run:

file.exists(f)

returned TRUE.

When I run:


dropbox_credentials<-dropbox_auth(mykey,mysecret,
.opts=list(cainfo=system.file("CurlSSL","cacert.pem",package="RCurl")),verbose=TRUE)

I get the following output:

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

duncantl commented 12 years ago

Thanks.

Looks like I had a ) in the wrong place so the verbose wasn't in the .opts. Can you run

dropbox_credentials<-dropbox_auth(mykey,mysecret, .opts=list(cainfo=system.file("CurlSSL","cacert.pem",package="RCurl"), verbose=TRUE))

Thanks D.

On 10/10/12 4:43 PM, Jared Knowles wrote:

Thanks for the persistence and the help. I am going to try it on another Windows box too, just in case. On this machine, when I run:

file.exists(f)

returned TRUE.

When I run:

dropbox_credentials<-dropbox_auth(mykey,mysecret, .opts=list(cainfo=system.file("CurlSSL","cacert.pem",package="RCurl")),verbose=TRUE)

I get the following output:

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

— Reply to this email directly or view it on GitHub https://github.com/karthikram/rDrop/issues/4#issuecomment-9323854.

jknowles commented 12 years ago

Yeah, I tried it both ways, but you get the same output either way. It doesn't seem like verbose is getting passed through that list.

I tried to put it outside of .opts, and even before .opts, but still get the same output.

duncantl commented 12 years ago

Aaah. That could be very instructive. If verbose isn't being passed to the curlPerform(), then neither is the cainfo. When I entered this discussion, I said something about "if" we could slip in curl options in to the call, but it seems we cannot. And looking at the dropbox_auth() code, I see why. (Karthik, we need to put the ... into the call to getCurlHandle() as the default value of the curl option.)

But we can still get where we want with the current code and hopefully a) it will work, or b) it will give us the output we need to diagnose the issue.

h = getCurlHandle(verbose = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))

dropbox_auth(mykey,mysecret, curl = h)

D.

On 10/10/12 4:53 PM, Jared Knowles wrote:

Yeah, I tried it both ways, but you get the same output either way. It doesn't seem like verbose is getting passed through that list.

I tried to put it outside of .opts, and even before .opts, but still get the same output.

— Reply to this email directly or view it on GitHub https://github.com/karthikram/rDrop/issues/4#issuecomment-9324044.

jknowles commented 12 years ago

It looks like getCurlHandle is not being passed through dropbox_auth()

I get the same error running the code above as well.

duncantl commented 12 years ago

Yes indeed.

A simple change to dropbox_auth() is

cred <- handshake(dropbox_oa, post = FALSE, verify = paste("Use the Web browser to grant permission to this code", "to access Dropbox on your behalf.\nWhen you see 'Success!', hit enter in R", sep = "\n"), curl = curl)

i.e. to pass the curl passed to dropbox_auth() to the handshake() function.

My guess is that will fix things.

However, another way around this problem is to set the default options used when creating an curl handle:

Use

options(RCurlOptions = c(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"), verbose = TRUE))

Then go ahead and call drobox_auth() and when it calls getCurlHandle() it "should" use these.

Thanks for your patience and perseverance.

D.

On 10/10/12 6:46 PM, Jared Knowles wrote:

It looks like getCurlHandle is not being passed through dropbox_auth()

I get the same error running the code above as well.

— Reply to this email directly or view it on GitHub https://github.com/karthikram/rDrop/issues/4#issuecomment-9326090.

jknowles commented 12 years ago

The options route worked perfectly. I got everything authorized and getCurlHandle used the right option!

Thank you so much for helping me work through it in the Windows instance.

If this is only a Windows issue maybe I can help update the documentation for Windows users?

SantoshSrinivas79 commented 10 years ago

@jknowles I am facing the same issue. What did you do to make it work correctly?

bhuston commented 10 years ago

I experienced the same issue as jknowles when I tried to use absolutely any of the functions in the rDrop package. However unlike him, setting the global options using the following code did not work for me:

options(RCurlOptions = c(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"), verbose = TRUE))

If I went this route, any subsequent rDrop functions that I tried to run gave me the following error:

dropbox_credentials <- dropbox_auth("mykey", "mysecret") # example R code

Error in curlSetOpt(..., .opts = .opts, curl = h, .encoding = .encoding) : # the error output VECTOR_ELT() can only be applied to a 'list', not a 'character'

I did manage to get around the rDrop SSL error by running the following though

h = getCurlHandle(verbose = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))

dropbox_auth(mykey,mysecret, curl = h)

If I now include the "curl= h" piece of code inside every rDrop function (not just dropbox_auth) when I run them everything works perfectly!

Anyway, I hope this is helpful. Thanks for the great package!

Ben

jakesherman commented 9 years ago

I was experiencing the same issue as @jknowles and company, and the solution proposed by @bhuston works perfectly. I am using Windows 8 and R 3.1.1. Thanks @bhuston!

jeffreyhanson commented 9 years ago

Hi,

I found this to work on Windows 7:

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

However, I had issues reusing a credentials object saved in a .rda between sessions.

I was planning on using this for a shiny app hosted on shinyapps.io, so in the end I just created credentials object in a linux vm and used that for the app, and now it works wonderfully!

Thanks for developing rDrop!

karthik commented 9 years ago

Thanks @paleo13!