Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of HTTPS (with self-signed cert) #36

Closed
ColinLeverger opened this issue Dec 4, 2017 · 13 comments
Closed

Support of HTTPS (with self-signed cert) #36

ColinLeverger opened this issue Dec 4, 2017 · 13 comments

Comments

@ColinLeverger
Copy link

I use a self-signed https cert on a server of mine, and it is not accepted by influxdbr.
I tried to configure curl with the following link: https://stackoverflow.com/questions/22048703/rcurl-and-self-signed-certificate-issues

How to reproduce

Code

# Install lib
install.packages("influxdbr")
install.packages("httr")

# Load lib for curl
library(httr)
# Configure your path for the cert
config(cainfo="C:some_path")

# Load libs
library(dplyr)
library(influxdbr)
library(xts)

# Create connection object 
con <- influx_connection(scheme = c("https"), host = "some_ip", port = 8086, 
                         user = "some_user", pass = "some_pass", 
                         path = "/", group = NULL,
                         verbose = TRUE)

Error

Error in curl::curl_fetch_memory(url, handle = handle) : 
  schannel: next InitializeSecurityContext failed: SEC_E_UNTRUSTED_ROOT (0x80090325) - The certificate chain was issued by an authority that is not trusted.
@dleutnant
Copy link
Owner

dleutnant commented Dec 4, 2017

Strange. We've got our InfluxDB with https running (and of course a working communication between R and InfluxDB).
Did you verify your HTTPS setup (link)?

@dleutnant dleutnant changed the title Support of HTTPS Support of HTTPS (with self-signed cert) Dec 4, 2017
@dleutnant
Copy link
Owner

dleutnant commented Dec 4, 2017

My first guess is that the relevant curl options are not interpreted.
Could you please submit a test ping with your settings and specifying your cainfo as {httr} option?

#submit test ping

response <- httr::GET(
  url = "",
  scheme = "https",
  hostname = "your_ip",
  port = 8086,
  path = "/ping",
  # HERE CAINFO as httr option
)

@dleutnant
Copy link
Owner

dleutnant commented Dec 4, 2017

also, maybe it helps to set the cainfo path globally:

httr::set_config(config(cainfo = 'C:some_path'))

@ColinLeverger
Copy link
Author

Thanks for your quick reply. I confirm that setting the parameter globally works perfectly fine. Now we could either:

  1. Document this solution in the README.md file,
  2. Code a boolean parameter in the influx_connection method, e.g selfsigned_cert: Boolean, which wrap this httr configuration inside the function.

I am willing to code/pull request, but my knowledge in R developing is relatively limited...

What worked for me:

httr::set_config(config(ssl_verifypeer = FALSE))

It was more convenient than setting the cainfo.

@dleutnant
Copy link
Owner

dleutnant commented Dec 5, 2017

Nice! Thanks! I think it would be straightforward to extend influx_connection with ... and pass those values to the httr::GET method. Of course, the connection object must contain those values which are then interpreted at httr::GET and httr::POST statements in

  • influx_ping,
  • influx_query,
  • influx_post and
  • influx_write.

With this approach you could either go the "global" or the "local" way.

@ColinLeverger
Copy link
Author

All right then, do you need some help for that?

@dleutnant
Copy link
Owner

dleutnant commented Dec 6, 2017

Yes! I'm going to commit the changes after some internal checks and would be happy if you could test the modified version then.

@dleutnant
Copy link
Owner

Would you like to give the dev version a try?

@dleutnant
Copy link
Owner

@ColinLeverger Did you have the chance to test the dev version?

@ColinLeverger
Copy link
Author

Hello @dleutnant, sorry to answer so late- I replied to an email I received about this thread, and my answer did not appear there for some reason...
I just told you in this "lost email" that I was not sure of the procedure to test the dev version, do you have any guidelines/docs?

@dleutnant
Copy link
Owner

No worries. I suggest to download the dev version via

# install.packages("remotes")
remotes::install_github("dleutnant/influxdbr@dev")

Afterwards, please use influxdbr::influx_connection with the required curl_options (s. help).

@ColinLeverger
Copy link
Author

It works for me with:

curl_options = httr::config(ssl_verifypeer = FALSE, ssl_verifyhost = FALSE)

All good, thanks! :-)

@dleutnant
Copy link
Owner

OK, thanks!

dleutnant added a commit that referenced this issue Jan 10, 2018
* prepare next dev

* clean up test db

* `influx_write` supports multiple measurements within one data.frame

* updated readme

* take path from influxdb_srv list

* additional curl options can be provided to influx_connection

* additional curl options can be provided to influx_connection (#36)

* Typo (#37)

* update news.md

* added IQL wrapper for `delete`

* typo

* fixes (#21, #38, #39)

* updated news

* prepare next cran release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants