Ignore SSL errors in R httr connection
Asked Answered
E

2

8

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.

Erlond answered 3/5, 2016 at 7:11 Comment(1)
readLines uses a file connection when given a character string, not a url one. Do it explicitly, or better, try httr. Also, you have some questionable syntax.Filefish
M
21

Simply run this line:

httr::set_config(config(ssl_verifypeer = 0L))
Mystify answered 16/6, 2016 at 0:33 Comment(0)
M
3

If someone is coming here looking for a solution for {httr2}, you can do it like this:

library(httr2)
req <- request("https://example.com") %>%
  req_options(ssl_verifypeer = 0)
Millner answered 10/6, 2022 at 10:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.