publish: Improve certificate verification

Remove colons and convert to lower case. hex.EncodeToString outputs a
lower case string.
This commit is contained in:
Thorben Günther 2023-08-25 22:36:00 +02:00
parent 25e65db8bd
commit ad2bc1fd89
No known key found for this signature in database
GPG key ID: 415CD778D8C5AFED

View file

@ -333,7 +333,8 @@ func (br *bridge) publish(n *notification) error {
req.Header.Set("Actions", fmt.Sprintf("http, Silence, %s, method=POST, body=%s%s", url, n.silenceBody, authString))
}
configFingerprint := br.cfg.Ntfy.CertFingerprint
// hex.EncodeToString outputs a lower case string
configFingerprint := strings.ToLower(strings.ReplaceAll(br.cfg.Ntfy.CertFingerprint, ":", ""))
if configFingerprint != "" {
tlsCfg := &tls.Config{}
tlsCfg.VerifyPeerCertificate = func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {