问题
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 = "xxxxx@yyyy.zzz",
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.
回答1:
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
回答2:
I got the following to work:
- Install libressl from source using the usual gnu configure/make/install sequence.
- 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.
- 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.
来源:https://stackoverflow.com/questions/34241049/rcurl-on-os-x-el-capitan-9806-error