Add TLS config options for notifiers using HTTP client

This commit is contained in:
CrazyMax
2025-08-31 13:31:43 +02:00
parent fd46218095
commit 288d3395c3
29 changed files with 274 additions and 99 deletions

25
pkg/utl/http.go Normal file
View File

@@ -0,0 +1,25 @@
package utl
import (
"crypto/tls"
"crypto/x509"
"os"
)
func LoadTLSConfig(insecureSkipVerify bool, caCertFiles []string) (*tls.Config, error) {
tlsConfig := &tls.Config{
InsecureSkipVerify: insecureSkipVerify,
}
if len(caCertFiles) > 0 {
certPool := x509.NewCertPool()
for _, caCertFile := range caCertFiles {
caCert, err := os.ReadFile(caCertFile)
if err != nil {
return nil, err
}
certPool.AppendCertsFromPEM(caCert)
}
tlsConfig.RootCAs = certPool
}
return tlsConfig, nil
}