support tls insecure due to cloudblade old TLS cert

This commit is contained in:
2026-07-05 14:53:10 -04:00
parent 059b89b5cd
commit a8e0a6ef1e
2 changed files with 12 additions and 0 deletions
+3
View File
@@ -22,6 +22,9 @@ type ServiceConfig struct {
EconetEmail string `yaml:"econetEmail" json:"econetEmail,omitempty" env:"ECONET_EMAIL"` EconetEmail string `yaml:"econetEmail" json:"econetEmail,omitempty" env:"ECONET_EMAIL"`
EconetPassword string `yaml:"econetPassword" json:"econetPassword,omitempty" env:"ECONET_PASSWORD"` EconetPassword string `yaml:"econetPassword" json:"econetPassword,omitempty" env:"ECONET_PASSWORD"`
// Necessary due to ancient TLS certificate run by cloudblade that isn't trusted in modern ca-certificate bundles
EconetTLSInsecure bool `yaml:"econetTLSInsecure" json:"econetTLSInsecure,omitempty" env:"ECONET_TLS_INSECURE" default:"false"`
// CostPerKWH is the electricity price in US dollars per kWh (e.g. 0.18 // CostPerKWH is the electricity price in US dollars per kWh (e.g. 0.18
// means 18 cents/kWh, NOT 18). It derives the econet_energy_cost_dollars // means 18 cents/kWh, NOT 18). It derives the econet_energy_cost_dollars
// metric from kWh energy usage. // metric from kWh energy usage.
+9
View File
@@ -5,8 +5,10 @@ package econet
import ( import (
"context" "context"
"crypto/tls"
"fmt" "fmt"
"log/slog" "log/slog"
"net/http"
rheemcloud "github.com/kevinburke/rheemcloud-go" rheemcloud "github.com/kevinburke/rheemcloud-go"
@@ -55,6 +57,13 @@ func connect(ctx context.Context, cfg *config.ServiceConfig) (*rheemcloud.Client
} }
client, err := rheemcloud.Connect(ctx, cfg.EconetEmail, cfg.EconetPassword, &rheemcloud.Config{ client, err := rheemcloud.Connect(ctx, cfg.EconetEmail, cfg.EconetPassword, &rheemcloud.Config{
Logger: slog.Default(), Logger: slog.Default(),
HTTPClient: &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: cfg.EconetTLSInsecure,
},
},
},
}) })
if err != nil { if err != nil {
return nil, fmt.Errorf("econet: connect failed: %w", err) return nil, fmt.Errorf("econet: connect failed: %w", err)