Fixed issue with shelly self signed certificate.
Build Docker image on push / docker (push) Successful in 20s
Build and push Docker image on tag / docker (push) Successful in 9s

This commit is contained in:
2026-08-18 01:00:56 +02:00
parent d9d989d63f
commit 9ec7a92fa1
5 changed files with 40 additions and 5 deletions
+13 -1
View File
@@ -3,6 +3,7 @@ package shelly
import (
"context"
"crypto/tls"
"encoding/json"
"fmt"
"io"
@@ -39,11 +40,22 @@ func NewClient(rawURL, username, password string, timeout time.Duration) (*Clien
username: username,
password: password,
httpClient: &http.Client{
Timeout: timeout,
Timeout: timeout,
Transport: insecureTLSTransport(),
},
}, nil
}
// insecureTLSTransport retains the standard HTTP transport behavior but accepts
// certificates that are expired, self-signed, or issued for another hostname.
func insecureTLSTransport() *http.Transport {
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig = &tls.Config{
InsecureSkipVerify: true, // #nosec G402 -- Shelly device certificates are intentionally not verified.
}
return transport
}
// GetStatus decodes the /status response into destination.
func (c *Client) GetStatus(ctx context.Context, destination any) error {
statusURL := *c.baseURL