Skip to content

Commit

Permalink
Replace deprecated CRL methods (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaarni authored Jan 24, 2024
1 parent 6dd40ac commit 75850d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ install:
go install -v ./cmd/certyaml

install-tools:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
go install github.com/securego/gosec/v2/cmd/gosec@v2.15.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2
go install github.com/securego/gosec/v2/cmd/gosec@v2.18.2

update-modules:
go get -u -t ./... && go mod tidy
8 changes: 4 additions & 4 deletions crl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ func TestRevocation(t *testing.T) {
assert.Nil(t, err)
certList, err := x509.ParseRevocationList(crlBytes)
assert.Nil(t, err)
assert.Equal(t, 2, len(certList.RevokedCertificates))
assert.Equal(t, 2, len(certList.RevokedCertificateEntries))
assert.Equal(t, "CN=ca", certList.Issuer.String())
assert.Equal(t, big.NewInt(123), certList.RevokedCertificates[0].SerialNumber)
assert.Equal(t, big.NewInt(456), certList.RevokedCertificates[1].SerialNumber)
assert.Equal(t, big.NewInt(123), certList.RevokedCertificateEntries[0].SerialNumber)
assert.Equal(t, big.NewInt(456), certList.RevokedCertificateEntries[1].SerialNumber)
}

func TestInvalidSelfSigned(t *testing.T) {
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestEmptyCRL(t *testing.T) {

certList, err := x509.ParseRevocationList(crlBytes)
assert.Nil(t, err)
assert.Equal(t, 0, len(certList.RevokedCertificates))
assert.Equal(t, 0, len(certList.RevokedCertificateEntries))
assert.Equal(t, "CN=ca", certList.Issuer.String())

// Empty CRL with no issuer cannot be created.
Expand Down
12 changes: 6 additions & 6 deletions internal/manifest/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestStateHandling(t *testing.T) {
err = GenerateCertificates(&output, "testdata/certs-state-1.yaml", path.Join(dir, "state.yaml"), dir)
assert.Nil(t, err)

// Check that calling generate again does not alter the state.
// Check stable hashing: calling generate again on same manifest does not alter the state.
h1, err := dirhash.HashDir(dir, "", dirhash.Hash1)
assert.Nil(t, err)
err = GenerateCertificates(&output, "testdata/certs-state-1.yaml", path.Join(dir, "state.yaml"), dir)
Expand Down Expand Up @@ -260,8 +260,8 @@ func TestRevocation(t *testing.T) {
certList, err := x509.ParseRevocationList(block.Bytes)
assert.Nil(t, err)
assert.Equal(t, "CN=ca1", certList.Issuer.String())
assert.Equal(t, 1, len(certList.RevokedCertificates))
assert.Equal(t, big.NewInt(123), certList.RevokedCertificates[0].SerialNumber)
assert.Equal(t, 1, len(certList.RevokedCertificateEntries))
assert.Equal(t, big.NewInt(123), certList.RevokedCertificateEntries[0].SerialNumber)

crlFile = path.Join(dir, "ca2-crl.pem")
pemBuffer, err = os.ReadFile(crlFile)
Expand All @@ -273,9 +273,9 @@ func TestRevocation(t *testing.T) {
certList, err = x509.ParseRevocationList(block.Bytes)
assert.Nil(t, err)
assert.Equal(t, "CN=ca2", certList.Issuer.String())
assert.Equal(t, 2, len(certList.RevokedCertificates))
assert.Equal(t, big.NewInt(123), certList.RevokedCertificates[0].SerialNumber)
assert.Equal(t, big.NewInt(456), certList.RevokedCertificates[1].SerialNumber)
assert.Equal(t, 2, len(certList.RevokedCertificateEntries))
assert.Equal(t, big.NewInt(123), certList.RevokedCertificateEntries[0].SerialNumber)
assert.Equal(t, big.NewInt(456), certList.RevokedCertificateEntries[1].SerialNumber)
}

func TestInvalidRevocation(t *testing.T) {
Expand Down

0 comments on commit 75850d9

Please sign in to comment.