Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add comment for signature decoding #380

Merged
merged 3 commits into from
Dec 2, 2022
Merged
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
6 changes: 6 additions & 0 deletions verifiers/internal/gcb/provenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,19 @@ func (self *Provenance) VerifyVersionedTag(tag string) error {

func decodeSignature(s string) ([]byte, []error) {
var errs []error
// First try the std decoding.
rsig, err := base64.StdEncoding.DecodeString(s)
if err == nil {
// No error, return the value.
return rsig, nil
}
errs = append(errs, err)

// If std decoding failed, try URL decoding.
// We try both because we encountered decoding failures
// during our tests. The DSSE documentation does not prescribe
// which encoding to use: `Either standard or URL-safe encoding is allowed`.
// https://github.com/secure-systems-lab/dsse/blob/27ce241dec575998dee8967c3c76d4edd5d6ee73/envelope.md#standard-json-envelope.
rsig, err = base64.URLEncoding.DecodeString(s)
if err == nil {
// No error, return the value.
Expand Down