Skip to content

Commit 1a6a8e8

Browse files
committed
Fix #4
1 parent 1ac9fc8 commit 1a6a8e8

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

cmd/certs/main.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ var (
4040
signCA bool
4141
sign bool
4242
file string
43+
44+
hostportRe = regexp.MustCompile(`([[:alnum:]\-\.]+):([[:digit:]]+)`)
4345
)
4446

4547
func init() {
@@ -209,8 +211,7 @@ func run() error {
209211
return nil
210212
}
211213

212-
re := regexp.MustCompile(`([[:alnum:]\.]+):([[:digit:]]+)`)
213-
matches := re.FindAllStringSubmatch(verify, -1)
214+
matches := hostportRe.FindAllStringSubmatch(verify, -1)
214215
if len(matches) == 0 {
215216
return fmt.Errorf("Issue parsing remote dns to check")
216217
}
@@ -222,7 +223,6 @@ func run() error {
222223
return err
223224
}
224225

225-
fmt.Println(host)
226226
err = certs.Verify(chain[0], chain[1:], host)
227227
if err != nil {
228228
err = fmt.Errorf("Certificate chain invalid %w", err)
@@ -272,8 +272,7 @@ func run() error {
272272
return nil
273273
}
274274

275-
re := regexp.MustCompile(`([[:alnum:]\.]+):([[:digit:]]+)`)
276-
matches := re.FindAllStringSubmatch(output, -1)
275+
matches := hostportRe.FindAllStringSubmatch(output, -1)
277276
if len(matches) == 0 {
278277
return fmt.Errorf("Issue parsing remote dns to check")
279278
}

tls.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"crypto/x509"
66
)
77

8-
func GetPeerServerCertificateChain(dns string) (pscc []*x509.Certificate, err error) {
8+
func GetPeerServerCertificateChain(uri string) (pscc []*x509.Certificate, err error) {
99
// Skip verification because we just want to get the certs to print
10-
conn, err := tls.Dial("tcp", dns, &tls.Config{InsecureSkipVerify: true}) // #nosec
10+
conn, err := tls.Dial("tcp", uri, &tls.Config{InsecureSkipVerify: true}) // #nosec
1111
if err != nil {
1212
return
1313
}

0 commit comments

Comments
 (0)