Skip to content

Commit

Permalink
Update to require SAN name or regex, do not allow just type
Browse files Browse the repository at this point in the history
Signed-off-by: Zach Steindler <[email protected]>
  • Loading branch information
steiza committed Jan 26, 2024
1 parent cadc390 commit 1d8be1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/verify/certificate_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s SubjectAlternativeNameMatcher) Verify(actualCert certificate.Summary) bo
}

func NewCertificateIdentity(sanMatcher SubjectAlternativeNameMatcher, extensions certificate.Extensions) (CertificateIdentity, error) {
if sanMatcher.SubjectAlternativeName.Type == "" && sanMatcher.SubjectAlternativeName.Value == "" && sanMatcher.Regexp.String() == "" {
if sanMatcher.SubjectAlternativeName.Value == "" && sanMatcher.Regexp.String() == "" {
return CertificateIdentity{}, errors.New("when verifying a certificate identity, there must be subject alternative name criteria")
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/verify/certificate_identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ func TestCertificateIdentityVerify(t *testing.T) {

func TestThatCertIDsAreFullySpecified(t *testing.T) {
_, err := NewShortCertificateIdentity("", "", "", "")
assert.NotNil(t, err)
assert.Error(t, err)

_, err = NewShortCertificateIdentity("foobar", "", "", "")
assert.NotNil(t, err)
assert.Error(t, err)

_, err = NewShortCertificateIdentity("", "URI", "", "")
assert.NotNil(t, err)
_, err = NewShortCertificateIdentity("", "", "", SigstoreSanRegex)
assert.Error(t, err)

_, err = NewShortCertificateIdentity("foobar", "URI", "", "")
_, err = NewShortCertificateIdentity("foobar", "", "", SigstoreSanRegex)
assert.Nil(t, err)
}

Expand Down

0 comments on commit 1d8be1e

Please sign in to comment.