Allow trusting self-signed certificates
This commit is contained in:
parent
60c46104c7
commit
eeef3f1fe8
2 changed files with 10 additions and 0 deletions
|
|
@ -353,6 +353,7 @@ uri: https://volkszaehler/api/data/<uuid>.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
|
||||
```
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue