RCurl on OS X El Capitan -9806 Error
Asked Answered
M

2

1

I am trying to use RCurl for an oauth 2 authentication. My code is:

library(RCurl)
myOpts <- curlOptions(httpheader =  
      c(Accept="application/json",
    "Content-Type"="application/x-www-form-urlencoded"))

token <- postForm(authURL, 
    .params = list(
        client_id ="aaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        client_secret = "bbbbbbbbbbbbbbbbbbbbbbbbbbbb",
        username = "[email protected]",
        password = pswd), 
    .opts = myOpts, 
    style="POST")

The code works just fine on R/Windows, but not on OS X El Capitan. On OS X, I get the error

Error in function (type, msg, asError = TRUE)  : 
SSLRead() return error -9806

I think it is a problem with SSL in the version of curl/libcurl that ships with OS X, and is documented elsewhere, but I haven't been able to figure out a fix. For what it's worth, I had similar problems with the httr package. How do I update curl and make it play nicely with RCurl?

My question is quite similar to How do I get RCurl to connect to POST SSL on OS X Yosemite?, but El Capitan has made it difficult to copy the curl-config file as suggested in the answer to that post.

Meeting answered 12/12, 2015 at 14:38 Comment(2)
I am interested in the answer to this.Expropriate
I've deleted my non-answer, but I must point out that your example remains insufficient to permit replication of the error.Eggbeater
M
0

I got the following to work:

  1. Install libressl from source using the usual gnu configure/make/install sequence.
  2. Install curl from source again using the usual gnu configure/make/install sequence. At the configure step, I needed to use the --with-ca-bundle option to point configure to a valid certificate file.
  3. Compile RCurl from source making sure /usr/local/bin comes earlier in the path list than /usr/bin so that RCurl's configure script finds curl-config from the new version of curl rather than from the os x default version.

I'd love to know if there's a better way.

Meeting answered 13/12, 2015 at 22:14 Comment(0)
E
0

You do not say what version of R or libcurl you are using or how they were installed, so a complete answer to your questions might need to take several pages to cover all the possible variations. El Capitan changed the security design. Do a google search on "rootless el capitan" or "el capitan system integrity protection". Most of /usr/ is now locked down by default, with the exception of /usr/local/. It's possible to temporarily disable that feature, but before you do so, I would advise checking to see if homebrew has been updated to accommodate this change. (I think it might have been using /usr/local/ all along.) I would also make sure that you understand how the homebrew installation process differs from what is expected by the maintainers of the OSX branches of R.

For comparison purposes I do have a functioning installation of RCurl, from the binary if IIRC, installed within a binary version of R 3.2.2 and my curl version reports look like.

machine-name-redacted-mac-pro:~ redacted$ curl --version
curl 7.43.0 (x86_64-apple-darwin15.0) libcurl/7.43.0 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets 

# and in R
> packageVersion("RCurl") 
[1] ‘1.95.4.7’

> system("which curl")
/usr/bin/curl
Eggbeater answered 12/12, 2015 at 17:15 Comment(1)
I'm using R 3.2.2, and my curl --version, packageVersion, and which curl are identical to yours. For the most part, RCurl works fine -- it's just the post+SSL that causes problems. I should also add that if install homebrew curl and point the compiler to the homebrew curl-config, I can build and install RCurl using the new libcurl. But, I haven't got it right because it makes R crash.Meeting
M
0

I got the following to work:

  1. Install libressl from source using the usual gnu configure/make/install sequence.
  2. Install curl from source again using the usual gnu configure/make/install sequence. At the configure step, I needed to use the --with-ca-bundle option to point configure to a valid certificate file.
  3. Compile RCurl from source making sure /usr/local/bin comes earlier in the path list than /usr/bin so that RCurl's configure script finds curl-config from the new version of curl rather than from the os x default version.

I'd love to know if there's a better way.

Meeting answered 13/12, 2015 at 22:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.