MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / FixSignatureInBundle

Function FixSignatureInBundle

pkg/attestation/attestations.go:120–129  ·  view source on GitHub ↗

FixSignatureInBundle removes any additional base64 encoding from the signature in the bundle. Kept for backward compatibility with attestations stored before the fix for https://github.com/chainloop-dev/chainloop/issues/1832, whose signatures are base64-encoded twice. New bundles produced by BundleF

(bundle *protobundle.Bundle)

Source from the content-addressed store, hash-verified

118// https://github.com/chainloop-dev/chainloop/issues/1832, whose signatures are base64-encoded twice.
119// New bundles produced by BundleFromDSSEEnvelope already carry a properly decoded signature.
120func FixSignatureInBundle(bundle *protobundle.Bundle) {
121 sig := bundle.GetDsseEnvelope().GetSignatures()[0].GetSig()
122 dst := make([]byte, base64.StdEncoding.EncodedLen(len(sig)))
123 i, err := base64.StdEncoding.Decode(dst, sig)
124 if err == nil {
125 // it was encoded twice. Use it
126 sig = dst[:i]
127 }
128 bundle.GetDsseEnvelope().GetSignatures()[0].Sig = sig
129}

Calls

no outgoing calls