Skip to content

Commit

Permalink
correct linting errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhundere committed Jun 3, 2024
1 parent cfda46f commit 9f34c30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/cosign/cli/verify/verify_blob_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,4 @@ func (c *VerifyBlobAttestationCommand) Exec(ctx context.Context, artifactPath st

fmt.Fprintln(os.Stderr, "Verified OK")
return nil
}
}
11 changes: 6 additions & 5 deletions pkg/cosign/tsalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ const (
// specified in `TSACertChainPath`. If using an alternate, the file should be in PEM format.
func GetTSACerts(ctx context.Context) (leaves [][]byte, intermediates [][]byte, roots [][]byte, err error) {
altTSACert := env.Getenv(env.VariableSigstoreTSACertificateFile)
tsaCertChainPath := os.Getenv("TSACertChainPath")
tsaCertChainPath := env.Getenv("TSACertChainPath")

if altTSACert != "" {
switch {
case altTSACert != "":
raw, err := os.ReadFile(altTSACert)
if err != nil {
return nil, nil, nil, fmt.Errorf("error reading alternate TSA certificate file: %w", err)
Expand All @@ -53,7 +54,7 @@ func GetTSACerts(ctx context.Context) (leaves [][]byte, intermediates [][]byte,

leavesPEM, intermediatesPEM, rootsPEM := convertCertsToPEM(leaves), convertCertsToPEM(intermediates), convertCertsToPEM(roots)
return leavesPEM, intermediatesPEM, rootsPEM, nil
} else if tsaCertChainPath != "" {
case tsaCertChainPath != "":
raw, err := os.ReadFile(tsaCertChainPath)
if err != nil {
return nil, nil, nil, fmt.Errorf("error reading TSA certificate chain path file: %w", err)
Expand All @@ -65,7 +66,7 @@ func GetTSACerts(ctx context.Context) (leaves [][]byte, intermediates [][]byte,

leavesPEM, intermediatesPEM, rootsPEM := convertCertsToPEM(leaves), convertCertsToPEM(intermediates), convertCertsToPEM(roots)
return leavesPEM, intermediatesPEM, rootsPEM, nil
} else {
default:
tufClient, err := tuf.NewFromEnv(ctx)
if err != nil {
return nil, nil, nil, err
Expand All @@ -92,7 +93,7 @@ func GetTSACerts(ctx context.Context) (leaves [][]byte, intermediates [][]byte,
}

func convertCertsToPEM(certs []*x509.Certificate) [][]byte {
var pemCerts [][]byte
pemCerts := make([][]byte, 0, len(certs)) // Pre-allocate with the number of certs
for _, cert := range certs {
block := &pem.Block{
Type: "CERTIFICATE",
Expand Down

0 comments on commit 9f34c30

Please sign in to comment.