diff --git a/README.md b/README.md index 41386994c5..fec0e4fad4 100644 --- a/README.md +++ b/README.md @@ -353,6 +353,7 @@ uri: https://volkszaehler/api/data/.json?from=now method: GET # default HTTP method headers: - content-type: application/json +insecure: false # set to true to trust self-signed certificates jq: .data.tuples[0][1] # parse response json scale: 0.001 # floating point factor applied to result, e.g. for kW to W conversion ``` diff --git a/provider/http.go b/provider/http.go index a5806e08a4..d00c6e5d32 100644 --- a/provider/http.go +++ b/provider/http.go @@ -1,6 +1,7 @@ package provider import ( + "crypto/tls" "fmt" "io" "math" @@ -32,6 +33,7 @@ func NewHTTPProviderFromConfig(log *util.Logger, other map[string]interface{}) * Body string Jq string Scale float64 + Insecure bool }{} util.DecodeOther(log, other, &cc) @@ -47,6 +49,13 @@ func NewHTTPProviderFromConfig(log *util.Logger, other map[string]interface{}) * scale: cc.Scale, } + // ignore the self signed certificate + if cc.Insecure { + customTransport := http.DefaultTransport.(*http.Transport).Clone() + customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + p.HTTPHelper.Client.Transport = customTransport + } + if cc.Jq != "" { op, err := gojq.Parse(cc.Jq) if err != nil {