Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/smokescreen/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func (config *Config) SetupCrls(crlFiles []string) error {

certList, err := x509.ParseCRL(crlBytes)
if err != nil {
log.Printf("Failed to parse CRL in '%s': %#v\n", crlFile, err)
return fmt.Errorf("failed to parse CRL in '%s': %w", crlFile, err)
}

// find the X509v3 Authority Key Identifier in the extensions (2.5.29.35)
Expand Down
34 changes: 34 additions & 0 deletions pkg/smokescreen/crl_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//go:build !nounit
// +build !nounit

package smokescreen

import (
"os"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// A CRL file that does not parse should be reported as a configuration error,
// not dereferenced.
func TestSetupCrlsRejectsUnparseableFile(t *testing.T) {
crlFile := filepath.Join(t.TempDir(), "bad.crl")
require.NoError(t, os.WriteFile(crlFile, []byte("this is not a CRL"), 0600))

conf := NewConfig()
err := conf.SetupCrls([]string{crlFile})

require.Error(t, err)
assert.Contains(t, err.Error(), crlFile)
}

func TestSetupCrlsReportsAMissingFile(t *testing.T) {
conf := NewConfig()

err := conf.SetupCrls([]string{filepath.Join(t.TempDir(), "absent.crl")})

assert.Error(t, err)
}