Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/projectdiscovery/tlsx into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsandeep committed Apr 27, 2023
2 parents 76c3f99 + 72f1c5d commit a9ceca0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/tlsx/clients/clients.go
Expand Up @@ -360,13 +360,13 @@ func IsMisMatchedCert(host string, alternativeNames []string) bool {
// match leftmost token
matched = matchWildCardToken(token, hostTokens[i])
if !matched {
return true
break
}
} else {
// match all other tokens
matched = stringsutil.EqualFoldAny(token, hostTokens[i])
if !matched {
return true
break
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/tlsx/clients/clients_test.go
Expand Up @@ -10,8 +10,8 @@ import (

func TestIsMisMatchedCert(t *testing.T) {
type args struct {
host string
names []string
host string // actual host name
names []string // cert names + alternate names
}

tests := []struct {
Expand All @@ -28,6 +28,10 @@ func TestIsMisMatchedCert(t *testing.T) {
{args{host: "foobaz.example.net", names: []string{"*baz.example.net"}}, false},
{args{host: "buzz.example.net", names: []string{"b*z.example.net"}}, false},

// multilevel domains
{args{host: "xyz.subdomain.target.com", names: []string{"*.target.com"}}, true},
{args{host: "xyz.subdomain.target.com", names: []string{"*.subdomain.target.com"}}, false},

// negative scenarios
{args{host: "bar.foo.example.net", names: []string{"*.example.net"}}, true},
{args{host: "target.com", names: []string{"other-target.com"}}, true},
Expand Down

0 comments on commit a9ceca0

Please sign in to comment.