Skip to content

Commit

Permalink
check status code in fulcio prober
Browse files Browse the repository at this point in the history
Signed-off-by: Hector Fernandez <hector@chainguard.dev>
  • Loading branch information
hectorj2f committed Dec 5, 2023
1 parent f2b97f5 commit 9463e98
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/prober/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func fulcioWriteEndpoint(ctx context.Context, priv *ecdsa.PrivateKey) (*x509.Cer
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusCreated {
body, _ := io.ReadAll(resp.Body)
return fmt.Errorf("invalid status code '%s' when requesting a cert from Fulcio with body '%s'", resp.Status, string(body))

Check failure on line 105 in cmd/prober/write.go

View workflow job for this annotation

GitHub Actions / lint

not enough return values

Check failure on line 105 in cmd/prober/write.go

View workflow job for this annotation

GitHub Actions / lint

not enough return values

Check failure on line 105 in cmd/prober/write.go

View workflow job for this annotation

GitHub Actions / lint

not enough return values

Check failure on line 105 in cmd/prober/write.go

View workflow job for this annotation

GitHub Actions / lint

not enough return values

Check failure on line 105 in cmd/prober/write.go

View workflow job for this annotation

GitHub Actions / lint

not enough return values
}

responseBody, err := io.ReadAll(resp.Body)
if err != nil {
Logger.Errorf("error reading response from Fulcio: %v", err)
Expand Down

0 comments on commit 9463e98

Please sign in to comment.