package check import ( "crypto/tls" "net" "strings" ) // TLS modes of services with optional encryption: "require" encrypts // without verifying the certificate, "verify" also verifies it. func validTLSMode(m string) bool { return m == "disable" || m == "require" || m == "verify" } // tlsFor returns the client TLS settings for mode, or nil for "disable". func tlsFor(mode, target string) *tls.Config { if mode == "disable" { return nil } host, _, _ := net.SplitHostPort(target) return &tls.Config{ServerName: host, InsecureSkipVerify: mode == "require"} //nolint:gosec // "require" encrypts without verifying, as chosen per monitor } // redact shortens err for customers and removes secrets some clients // repeat in their errors. func redact(err error, secrets ...string) string { msg := err.Error() for _, s := range secrets { if s != "" { msg = strings.ReplaceAll(msg, s, "***") } } return truncate(msg, 300) }