mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
fix(updater): accept tauri base64-wrapped minisign signatures
`tauri signer sign` emits .sig files that are base64-wrapped minisign
documents — the same wrapping already handled for the pinned public key —
but verifySignatureReader fed the wrapped text straight to
minisign.Signature.UnmarshalText, so every real release signature failed to
parse ("minisign: invalid signature"). Unwrap base64 when the text is not a
raw minisign document; raw documents (and the test fixtures) pass through
unchanged.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -555,7 +555,7 @@ func (u *Updater) verifySignatureReader(reader io.Reader, signatureText []byte,
|
||||
return fmt.Errorf("reading file for signature verification: %w", err)
|
||||
}
|
||||
|
||||
normalizedSig := []byte(strings.TrimSpace(string(signatureText)))
|
||||
normalizedSig := normalizeSignatureText(signatureText)
|
||||
var parsedSig minisign.Signature
|
||||
if err := parsedSig.UnmarshalText(normalizedSig); err != nil {
|
||||
return fmt.Errorf("invalid update signature format: %w", err)
|
||||
@@ -567,6 +567,21 @@ func (u *Updater) verifySignatureReader(reader io.Reader, signatureText []byte,
|
||||
return nil
|
||||
}
|
||||
|
||||
// normalizeSignatureText returns the raw minisign signature document from
|
||||
// signatureText. `tauri signer sign` emits .sig files that are base64-wrapped
|
||||
// minisign documents (the same wrapping used for the pinned public key file);
|
||||
// raw minisign documents pass through unchanged.
|
||||
func normalizeSignatureText(signatureText []byte) []byte {
|
||||
trimmed := []byte(strings.TrimSpace(string(signatureText)))
|
||||
if bytes.HasPrefix(trimmed, []byte("untrusted comment:")) {
|
||||
return trimmed
|
||||
}
|
||||
if decoded, err := base64.StdEncoding.DecodeString(string(trimmed)); err == nil {
|
||||
return []byte(strings.TrimSpace(string(decoded)))
|
||||
}
|
||||
return trimmed
|
||||
}
|
||||
|
||||
func (u *Updater) serverSignaturePublicKey() (minisign.PublicKey, error) {
|
||||
decoded, err := base64.StdEncoding.DecodeString(u.signingKeyText)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user