1
0
Fork 0
mirror of https://github.com/Luzifer/promcertcheck.git synced 2024-11-09 16:30:04 +00:00

Add support for ports in probe-URLs

This commit is contained in:
Knut Ahlers 2016-09-29 11:40:55 +02:00
parent 093c7348db
commit 90f6432443
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -53,9 +53,12 @@ func checkCertificate(probeURL *url.URL) (probeResult, *x509.Certificate) {
intermediatePool := x509.NewCertPool() intermediatePool := x509.NewCertPool()
var verifyCert *x509.Certificate var verifyCert *x509.Certificate
hostPort := strings.Split(probeURL.Host, ":")
host := hostPort[0]
for _, cert := range resp.TLS.PeerCertificates { for _, cert := range resp.TLS.PeerCertificates {
wildHost := "*" + probeURL.Host[strings.Index(probeURL.Host, "."):] wildHost := "*" + host[strings.Index(host, "."):]
if !inSlice(cert.DNSNames, probeURL.Host) && !inSlice(cert.DNSNames, wildHost) { if !inSlice(cert.DNSNames, host) && !inSlice(cert.DNSNames, wildHost) {
intermediatePool.AddCert(cert) intermediatePool.AddCert(cert)
continue continue
} }