Skip to content

Commit

Permalink
Fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
taybart committed Mar 3, 2021
1 parent 1ac9fc8 commit 1a6a8e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions cmd/certs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ var (
signCA bool
sign bool
file string

hostportRe = regexp.MustCompile(`([[:alnum:]\-\.]+):([[:digit:]]+)`)
)

func init() {
Expand Down Expand Up @@ -209,8 +211,7 @@ func run() error {
return nil
}

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

fmt.Println(host)
err = certs.Verify(chain[0], chain[1:], host)
if err != nil {
err = fmt.Errorf("Certificate chain invalid %w", err)
Expand Down Expand Up @@ -272,8 +272,7 @@ func run() error {
return nil
}

re := regexp.MustCompile(`([[:alnum:]\.]+):([[:digit:]]+)`)
matches := re.FindAllStringSubmatch(output, -1)
matches := hostportRe.FindAllStringSubmatch(output, -1)
if len(matches) == 0 {
return fmt.Errorf("Issue parsing remote dns to check")
}
Expand Down
4 changes: 2 additions & 2 deletions tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"crypto/x509"
)

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

0 comments on commit 1a6a8e8

Please sign in to comment.