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)
| 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. |
| 120 | func 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 | } |
no outgoing calls