From 9c886d497e89c4e0a43aff0c14d327c5473a7706 Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Sat, 5 May 2018 23:46:12 +0200 Subject: [PATCH] [TASK] allow self-signed certification in influxdb --- database/influxdb/database.go | 13 ++++++++++--- database/influxdb/database_test.go | 7 ++++--- docs/docs_configuration.md | 10 ++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/database/influxdb/database.go b/database/influxdb/database.go index b59a6fb..f580e2e 100644 --- a/database/influxdb/database.go +++ b/database/influxdb/database.go @@ -45,6 +45,12 @@ func (c Config) Username() string { func (c Config) Password() string { return c["password"].(string) } +func (c Config) InsecureSkipVerify() bool { + if d, ok := c["insecure_skip_verify"]; ok { + return d.(bool) + } + return false +} func (c Config) Tags() map[string]interface{} { if c["tags"] != nil { return c["tags"].(map[string]interface{}) @@ -61,9 +67,10 @@ func Connect(configuration map[string]interface{}) (database.Connection, error) // Make client c, err := client.NewHTTPClient(client.HTTPConfig{ - Addr: config.Address(), - Username: config.Username(), - Password: config.Password(), + Addr: config.Address(), + Username: config.Username(), + Password: config.Password(), + InsecureSkipVerify: config.InsecureSkipVerify(), }) if err != nil { diff --git a/database/influxdb/database_test.go b/database/influxdb/database_test.go index 9a7e8aa..b512d3b 100644 --- a/database/influxdb/database_test.go +++ b/database/influxdb/database_test.go @@ -16,9 +16,10 @@ func TestConnect(t *testing.T) { assert := assert.New(t) conn, err := Connect(map[string]interface{}{ - "address": "", - "username": "", - "password": "", + "address": "", + "username": "", + "password": "", + "insecure_skip_verify": true, }) assert.Nil(conn) assert.Error(err) diff --git a/docs/docs_configuration.md b/docs/docs_configuration.md index 14f86ab..4c5d406 100644 --- a/docs/docs_configuration.md +++ b/docs/docs_configuration.md @@ -569,6 +569,7 @@ address = "http://localhost:8086" database = "ffhb" username = "" password = "" +insecure_skip_verify = false [database.connection.influxdb.tags] tagname1 = "tagvalue 1" system = "productive" @@ -616,6 +617,15 @@ password = "" ``` {% endmethod %} +### insecure_skip_verify +{% method %} +Skip insecure verify for self-signed certificates. +{% sample lang="toml" %} +```toml +insecure_skip_verify = true +``` +{% endmethod %} + ### [database.connection.influxdb.tags] {% method %}