Skip to content

Commit

Permalink
fix: oid contains
Browse files Browse the repository at this point in the history
  • Loading branch information
Laisky committed Jan 17, 2023
1 parent 266a36e commit 421011c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions encrypt/x509.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func (o *oidContainsOption) applyfs(fs ...func(o *oidContainsOption) error) *oid

// MatchPrefix treat prefix inclusion as a match as well
//
// `1.2.3.4` contains `1.2.3`
// `1.2.3` contains `1.2.3.4`
func MatchPrefix() func(o *oidContainsOption) error {
return func(o *oidContainsOption) error {
o.prefix = true
Expand All @@ -496,7 +496,7 @@ func OIDContains(oids []asn1.ObjectIdentifier,
return true
}

if opt.prefix && strings.HasPrefix(oid.String(), oids[i].String()) {
if opt.prefix && strings.HasPrefix(oids[i].String(), oid.String()) {
return true
}
}
Expand Down
2 changes: 1 addition & 1 deletion encrypt/x509_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,5 @@ func Test_OIDs(t *testing.T) {
require.True(t, OIDContains(ca.PolicyIdentifiers, a1))
require.True(t, OIDContains(ca.PolicyIdentifiers, a2))
require.False(t, OIDContains(ca.PolicyIdentifiers, a3))
require.True(t, OIDContains(ca.PolicyIdentifiers, a3, MatchPrefix()))
require.True(t, OIDContains(ca.PolicyIdentifiers, asn1.ObjectIdentifier{1, 2}, MatchPrefix()))
}

0 comments on commit 421011c

Please sign in to comment.