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.

KillerSnail
  • 3,321
  • 11
  • 46
  • 64
  • `readLines` uses a `file` connection when given a character string, not a `url` one. Do it explicitly, or better, try [`httr`](https://github.com/hadley/httr/). Also, you have some questionable syntax. – alistaire May 03 '16 at 07:23

2 Answers2

20

Simply run this line:

httr::set_config(config(ssl_verifypeer = 0L))
RobertMyles
  • 2,673
  • 3
  • 30
  • 45
user6472132
  • 209
  • 1
  • 4
1

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)
Stefan F
  • 2,573
  • 1
  • 17
  • 19