天道酬勤,学无止境

Ignore SSL errors in R httr connection

Updated:

I am trying to access a corporate internal web API using:

require(httr)
url = 'https://my_server/api/search/query?q=stuff'
httr::set_config( config(ssl_verifypeer = 0L) )
data <- httr::GET( url, use_proxy(url = "ipaddress:port"), verbose() )

I get:

-> CONNECT my_server:port HTTP/1.1
-> Host: my_server:port
-> User-Agent: libcurl/7.47.1 r-curl/0.9.7 httr/1.1.0
-> Proxy-Connection: Keep-Alive
-> 
<- HTTP/1.1 200 Connection established
<- 
Error in curl::curl_fetch_memory(url, handle = handle) : 
  SSL connect error    

I used ssl_verifypeer as there are issues with the CA cert of the server. is that what is causing the issue with the SSL connect error ?

How do I bypass this and get the data? is there a way to flick the --insecure option that exists if you run in the linux command line? Note I am running R on windows though.

标签

评论

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

相关推荐
  • devtools :: install_github()-忽略SSL证书验证失败(devtools::install_github() - Ignore SSL cert verification failure)
    问题 我正在尝试让devtools::install_github()在Windows 7上的公司代理后面工作。 到目前为止,我必须执行以下操作: > library(httr) > library(devtools) > set_config(use_proxy("123.123.123.123",8080)) > devtools::install_github("rstudio/ggvis") Installing github repo ggvis/master from rstudio Downloading master.zip from https://github.com/rstudio/ggvis/archive/master.zip 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 显然,我们有某种证书服务器将SSL证书替换为我们自己的公司SSL证书(通过转至https://github.com并检查证书进行确认)。 无论如何
  • 在 R 中使用 httr 通过 SSL 获取站点内容(Get site content over SSL with httr in R)
    问题 我正在尝试使用 R 中的 HTTP POST 方法从我的服务器获取一个 JSON 数组。 我同时使用试图POST从功能httr和getURL从功能RCurl但都返回错误。 cafile <- system.file("CurlSSL", "cacert.pem", package = "RCurl") url <- "https://example.com/query/getData.php" POST(url,body=NULL) POST(url,body=NULL,config(cainfo=cafile)) getURL(url) getURL(url,cainfo=cafile) POST函数给出的错误是(对于两个调用): Error in curl::curl_fetch_memory(url, handle = handle) : SSL peer certificate or SSH remote key was not OK getURL函数给出的错误是(没有config(cainfo=cafile) ): * Hostname was NOT found in DNS cache * Trying 162.xxx.xxx.xxx... * connect to 162.xxx.xxx.xxx port 443 failed: Connection
  • Get site content over SSL with httr in R
    I'm trying to fetch a JSON array from my server using the HTTP POST method in R. I've tried using both the POSTfunction from httrand the getURLfunction from RCurl but both return errors. cafile <- system.file("CurlSSL", "cacert.pem", package = "RCurl") url <- "https://example.com/query/getData.php" POST(url,body=NULL) POST(url,body=NULL,config(cainfo=cafile)) getURL(url) getURL(url,cainfo=cafile) The error given by the POST function is (for both calls): Error in curl::curl_fetch_memory(url, handle = handle) : SSL peer certificate or SSH remote key was not OK The error given by the getURL
  • 使用 Kerberos 身份验证建立连接(Establish a connection using Kerberos Authentication)
    问题 我正在尝试使用 kerberos 身份验证建立连接。 我认为我的问题不取决于服务器的类型(在我的情况下是 cognos tm1 服务器)也不取决于语言(在我的情况下是 R 使用包 httr(或 RCurl)),因为它更像是一个通用的 http( s) 的事情。 我没有太多使用 kerberos 的经验。 根据我的理解,客户端和服务器之间会按照以下步骤进行一些协商(这里是 get-requests)。 我唯一需要传递的是用户名,不需要密码。 get(url) -> 返回一个 "WWW-Authenticate: Kerberos" 标头,告诉这个 authmethod 是受支持的。 get(url, header = Authentification: "Negotiate" + token ) --> 第二个请求,这次是头信息“Negotiate”加上令牌服务器返回一些认证细节。 接收到的详细信息可以再次在标题中发送,并发送回请求的数据 httr (type = gssnegotiate) 或 curl (4 = CURLAUTH_NEGOTIATE) 允许输入协商类型。 我想,这应该执行上述协商过程并直接返回请求的数据。 情况似乎并非如此: library(httr) httr::set_config(config( ssl_verifypeer = 0L)) httr
  • Establish a connection using Kerberos Authentication
    I'm trying to establish a connection using kerberos authentication. I think the question I have does not depend on the type of server (in my case it's a cognos tm1 server) nor the language (in my case R with use of the package httr (or RCurl)) since it's more a general http(s) thing. I do not have much experience using kerberos. According to my understanding there is some negotiation between the client and server following the following steps (here get-requests). The only thin I need to pass is a username, no password is needed. get(url) -> returning a "WWW-Authenticate: Kerberos" header
  • how to authenticate a shibboleth multi-hostname website with httr in R
    note: ipums international and ipums usa probably use the same system. ipums usa allows quicker signup. if you would like to test out your code, try https://usa.ipums.org/usa-action/users/request_access to sign up! i am trying to programmatically download a file from https://international.ipums.org/ with the R language and httr. i need to use httr and not RCurl because i need to post-authentication download large files not into RAM but directly to disk. this is currently only possible with httr as far as i know the reproducible code below documents my best effort at getting from the login page
  • 如何在 R 中使用 httr 对 shibboleth 多主机名网站进行身份验证(how to authenticate a shibboleth multi-hostname website with httr in R)
    问题 注意:ipums international 和 ipums usa 可能使用相同的系统。 ipums usa 允许更快的注册。 如果您想测试您的代码,请尝试 https://usa.ipums.org/usa-action/users/request_access 进行注册! 我正在尝试使用 R 语言和 httr 以编程方式从 https://international.ipums.org/ 下载文件。 我需要使用 httr 而不是 RCurl,因为我需要在身份验证后下载大文件,而不是下载到 RAM 中,而是直接下载到磁盘。 据我所知,目前这只能通过 httr 实现 下面的可重现代码记录了我从登录页面 (https://international.ipums.org/international-action/users/login) 到主认证后页面的最大努力。 任何提示或提示将不胜感激! 谢谢! my_email <- "email@address.com" my_password <- "password" tf <- tempfile() # use httr, because i need to download a large file after authentication # and only httr supports that with its
  • SSL 验证导致 RCurl 和 httr 中断 - 在应该合法的网站上(SSL verification causes RCurl and httr to break - on a website that should be legit)
    问题 我正在尝试自动登录英国的数据存档服务。 该网站显然值得信赖。 不幸的是, RCurl和httr在 SSL 验证时httr中断。 我的网络浏览器没有发出任何警告。 我可以通过在RCurl使用ssl.verifypeer = FALSE来解决这个问题,但我想了解发生了什么? # breaks library(httr) GET( "https://www.esds.ac.uk/secure/UKDSRegister_start.asp" ) # breaks library(RCurl) cert <- system.file("CurlSSL/cacert.pem", package = "RCurl") getURL("https://www.esds.ac.uk/secure/UKDSRegister_start.asp",cainfo = cert) # works library(RCurl) getURL( "https://www.esds.ac.uk/secure/UKDSRegister_start.asp" , .opts = list(ssl.verifypeer = FALSE) ) # note: use list(ssl.verifypeer = FALSE,followlocation=TRUE) to see content 回答1 TL; 博士
  • RCurl getURL SSL 错误(RCurl getURL SSL error)
    问题 相关问题: 获取 ssl 端点时出现 RCurl 错误 R:在 Rcurl getURL 语句中指定 SSL 版本 我正在查看以下内容: url = https://www.veilingbiljet.nl/resultaten-ajax.asp?order=datum&direction=D&page=1&field=0&regio=39 然后, getURL(url) 给出以下错误: error:1411809D:SSL routines:SSL_CHECK_SERVERHELLO_TLSEXT:tls invalid ecpointformat list 添加以下相关问题之一中建议的 followinf curl 选项, getURL(url, ssl.verifypeer = TRUE,sslversion=3L) 返回 Unknown SSL protocol error in connection to www.veilingbiljet.nl:443 任何帮助将不胜感激。 回答1 RCurl包未维护且已不复存在。 使用curl包或httr代替: library(curl) con <- curl("https://www.veilingbiljet.nl/resultaten-ajax.asp?order=datum&direction=D&page=1
  • devtools :: install_github失败,并显示CA证书错误(devtools::install_github fails with CA cert error)
    问题 当我尝试调用install_github时,出现以下错误(不仅针对此软件包,而且针对所有github软件包): > install_github('ramnathv/slidify') Downloading github repo ramnathv/slidify@master Error in curl::curl_fetch_memory(url, handle = handle) : Problem with the SSL CA cert (path? access rights?) 但是,如果我直接使用RCurl使用ssl访问github,我不会遇到任何问题: > x <- getBinaryURL( url='https://github.com/ramnathv/slidify/archive/master.zip', followlocation=1L ) 可以正常工作,因此RCurl可以正确验证SSL证书并下载存档文件。 > sessionInfo() R version 3.2.1 (2015-06-18) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian GNU/Linux 8 (jessie) locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC
  • R-install_github失败(R - install_github fails)
    问题 我正在尝试从R中的github安装一个软件包,但是出现以下错误: > install_github("jmp75/rClr", build_vignettes=TRUE) Downloading github repo jmp75/rClr@master Error in curl::curl_fetch_memory(url, handle = handle) : Peer certificate cannot be authenticated with given CA certificates 我已经将RCurl选项设置为: options(RCurlOptions = c(getOption("RCurlOptions"), ssl.verifypeer = FALSE, ssl.verifyhost = FALSE ) ) 检查设置后: getOption("RCurlOptions") 我们看.... $cainfo [1] "C:/_CODE/R/Library/RCurl/etc/ca-bundle.crt" $ssl.verifypeer [1] FALSE $ssl.verifyhost [1] FALSE 仍然我得到错误: Downloading github repo jmp75/rClr@master Error in curl::curl
  • quantmod - SSL:无法在 R 中获得本地颁发者证书(quantmod - SSL: unable to get local issuer certificate in R)
    问题 我正在尝试在 R 中使用quantmod包从雅虎获取财务数据。 它在我的个人笔记本电脑(Mac 和 Win)上运行完美。 但是我不能让它在我的工作计算机(Win7)上运行。 我的代码是: getSymbols("JPM", src = "yahoo") 请注意,它仅不适用于我公司的笔记本电脑。 这是错误代码: Error in curl::curl_download(cu, tmp, handle = h) : SSL certificate problem: unable to get local issuer certificate 我尝试通过以下方式解决问题: 安装httr包删除curl 、 quantmod并重新安装更新到最新版本的 R、RStudio、 curl 、 httr 、 RCurl和quantmod 安装openssl包设置ssl_verifypeer = 0L 在getSymbols之前添加以下getSymbols options(download.file.method = "wget", download.file.extra = c("--no-check-certificate")) 不幸的是,上述方法均无效。 顺便说一句,从谷歌金融工作中获取数据,但谷歌每个请求只提供约 4000 条记录。 我认为我们公司对 SSL 有一些限制
  • devtools::install_github() - Ignore SSL cert verification failure
    I'm trying to get devtools::install_github() working behind my corporate proxy on Windows 7. So far I've had to do the following: > library(httr) > library(devtools) > set_config(use_proxy("123.123.123.123",8080)) > devtools::install_github("rstudio/ggvis") Installing github repo ggvis/master from rstudio Downloading master.zip from https://github.com/rstudio/ggvis/archive/master.zip 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 Apparently we have
  • quantmod - SSL: unable to get local issuer certificate in R
    I’m trying to use quantmod package in R to get financial data from Yahoo. It works perfectly on my personal laptops (Mac and Win). But I cannot make it work on my working computer (Win7). My code is: getSymbols("JPM", src = "yahoo") Please note it only doesn't work on my company laptop. Here's the error code: Error in curl::curl_download(cu, tmp, handle = h) : SSL certificate problem: unable to get local issuer certificate I have tried to solve the problems in the following ways: install httr package Delete curl, quantmod and reinstall Update to the latest version of R, RStudio, curl, httr
  • 如何使用 httr GET 命令刷新或重试特定网页?(How to refresh or retry a specific web page using httr GET command?)
    问题 我需要使用不同的“密钥”访问同一个网页以获取它提供的特定内容。 我有一个键x的列表,我使用httr包中的GET命令访问网页,然后检索我需要的信息y 。 library(httr) library(stringr) library(XML) for (i in 1:20){ h1 = GET ( paste0("http:....categories=&query=", x[i]),timeout(10)) par = htmlParse(file = h1) y[i]=xpathSApply(doc = par, path = "//h3/a" , fun=xmlValue) } 问题是经常达到超时,它会破坏循环。 因此,如果达到超时,我想刷新网页或重试 GET 命令,因为我怀疑问题出在我尝试访问的网站的 Internet 连接上。 我的代码的工作方式,超时打破了循环。 我需要忽略错误并转到下一次迭代或重试访问该网站。 回答1 看看purrr::safely() 。 您可以这样包装GET : safe_GET <- purrr::safely(GET) 这通过让您执行以下操作来消除tryCatch()的丑陋之tryCatch() : resp <- safe_GET("http://example.com") # you can use all legal `GET`
  • 使用RCurl或httr在R中自动登录到英国数据服务网站(automating the login to the uk data service website in R with RCurl or httr)
    问题 我正在为http://asdfree.com/编写可免费下载的R脚本集合,以帮助人们分析英国数据服务托管的复杂样本调查数据。 除了为这些数据集提供大量的统计教程之外,我还希望自动化此调查数据的下载和导入。 为此,我需要弄清楚如何以编程方式登录到此英国数据服务网站。 我尝试了许多不同配置的RCurl和httr登录,但是我在某个地方犯了一个错误,被卡住了。 我已经尝试检查了这篇文章中概述的元素,但是这些网站在浏览器中的跳转速度太快了,以至于我无法理解正在发生的事情。 该网站确实需要登录名和密码,但是我认为在进入登录页面之前我犯了一个错误。 网站的运作方式如下: 起始页应为:https://www.esds.ac.uk/secure/UKDSRegister_start.asp 此页面将自动将您的Web浏览器重定向到以以下网址开头的长网址: https://wayf.ukfederation.org.uk/DS002/uk.ds?[blahblahblah] : https://wayf.ukfederation.org.uk/DS002/uk.ds?[blahblahblah] (1)由于某些原因,SSL证书在本网站上不起作用。 这是我对此发布的SO问题。 我使用的解决方法只是忽略SSL: library(httr) set_config( config( ssl
  • 如何使用 httr 为基于证书的身份验证指定证书、密钥和根证书?(How to specify certificate, key and root certificate with httr for certificate based authentication?)
    问题 我正在尝试使用 httr 库从需要基于证书的身份验证的服务器访问数据。 我有证书 (cert.pem)、密钥文件 (key.pem) 和根证书 (caroot.pem) 以下 curl 有效。 curl -H "userName:sriharsha@rpc.com" --cert cert.pem --key certkey.key --cacert caroot.pem https://api.somedomain.com/api/v1/timeseries/klog?limit= 1 如何指定 certkey.key 和 caroot.pem 到 httr GET 请求。 我正在尝试使用以下 R 命令,但找不到指定证书密钥和 caroot 的选项。 咖啡馆=???? r<-GET("https://api.somedomain.com/api/v1/timeseries/klog", query = list(limit = 1), add_headers("userName"="sriharsha@rpc.com"), config (cainfo = cafile,ssl_verifypeer=FALSE),详细()) 因此,我正在为 curl 的(--cert、--key 和--cacert)寻找 httr 的等效选项。 回答1 基于 curl 文档,选项为 ssl
  • automating the login to the uk data service website in R with RCurl or httr
    I am in the process of writing a collection of freely-downloadable R scripts for http://asdfree.com/ to help people analyze the complex sample survey data hosted by the UK data service. In addition to providing lots of statistics tutorials for these data sets, I also want to automate the download and importation of this survey data. In order to do that, I need to figure out how to programmatically log into this UK data service website. I have tried lots of different configurations of RCurl and httr to log in, but I'm making a mistake somewhere and I'm stuck. I have tried inspecting the
  • devtools::install_github fails with CA cert error
    When I try to call install_github, I get the following error (not just for this package, but for all github packages): > install_github('ramnathv/slidify') Downloading github repo ramnathv/slidify@master Error in curl::curl_fetch_memory(url, handle = handle) : Problem with the SSL CA cert (path? access rights?) But if I use RCurl directly to access github with ssl, I don't get any problem: > x <- getBinaryURL( url='https://github.com/ramnathv/slidify/archive/master.zip', followlocation=1L ) works with no errors, so RCurl can verify the SSL certificate properly and download the archive file. >
  • checkError(res) 中的错误:httr 调用中的未定义错误。 httr 输出:无法连接到本地主机端口 4445:连接被拒绝(Error in checkError(res) : Undefined error in httr call. httr output: Failed to connect to localhost port 4445: Connection refused)
    问题 我尝试使用 RSelenium 打开远程驱动程序,但我一直面临着与 Docker 相同的问题。 在 Docker 中,我运行 $ docker run -d -p 4445:4444 selenium/standalone-firefox:2.53.0 然后 $ docker ps Docker 回归 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a89435c68373 selenium/standalone-firefox:2.53.0 "/opt/bin/entry_poin…" About an hour ago Up About an hour 0.0.0.0:4445->4444/tcp determined_sammet 然后在 R remDr <- remoteDriver(port = 4445L) remDr$open() 我收到这个错误 Error in checkError(res) : Undefined error in httr call. httr output: Failed to connect to localhost port 4445: Connection refused 我不知道如何处理这个。 任何人都可以帮忙吗? 谢谢 感谢 Ralf Stubner 命令 remDr