From 90f643244371361b6f5cacd466b7675f6f66d558 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 29 Sep 2016 11:40:55 +0200 Subject: [PATCH] Add support for ports in probe-URLs --- cert.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cert.go b/cert.go index 50622a2..3d3e2c9 100644 --- a/cert.go +++ b/cert.go @@ -53,9 +53,12 @@ func checkCertificate(probeURL *url.URL) (probeResult, *x509.Certificate) { intermediatePool := x509.NewCertPool() var verifyCert *x509.Certificate + hostPort := strings.Split(probeURL.Host, ":") + host := hostPort[0] + for _, cert := range resp.TLS.PeerCertificates { - wildHost := "*" + probeURL.Host[strings.Index(probeURL.Host, "."):] - if !inSlice(cert.DNSNames, probeURL.Host) && !inSlice(cert.DNSNames, wildHost) { + wildHost := "*" + host[strings.Index(host, "."):] + if !inSlice(cert.DNSNames, host) && !inSlice(cert.DNSNames, wildHost) { intermediatePool.AddCert(cert) continue }