protondrive: say how to read a file whose signature fails to verify
The error for a content key or manifest signature which fails now ends with a hint to set ignore_signature_errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6e2410de69
commit
14128d59c0
2 files changed
+8
-2
No files matched your search
@@ -33,6 +33,10 @@ var (
|
||||
errDownloadClosed = errors.New("download closed")
|
||||
)
|
||||
|
||||
// signatureHint ends an error for a signature which fails, telling the
|
||||
// user how to read the file anyway.
|
||||
const signatureHint = "set ignore_signature_errors to read the file anyway"
|
||||
|
||||
const (
|
||||
// defaultBlockSize is the plaintext size of every block but the
|
||||
// last of a file which doesn't record its block sizes.
|
||||
@@ -183,7 +187,7 @@ func (c *client) contentKey(n *node) (*crypto.SessionKey, error) {
|
||||
if verifyErr != nil {
|
||||
verifyErr = fmt.Errorf("content key: %w: %w", errIntegrity, verifyErr)
|
||||
if !c.opt.IgnoreSignatureErrors {
|
||||
return nil, verifyErr
|
||||
return nil, fmt.Errorf("%w: %s", verifyErr, signatureHint)
|
||||
}
|
||||
c.reportOnce("content key", n.ID, func() {
|
||||
fs.Errorf(nil, "protondrive: %q (ID %s): %v", n.Name, n.ID, verifyErr)
|
||||
@@ -404,7 +408,7 @@ func (r *blockReader) verifyManifest(hashes [][]byte, manifest, signer string) e
|
||||
}
|
||||
err = fmt.Errorf("%w: %w", errIntegrity, err)
|
||||
if !r.c.opt.IgnoreSignatureErrors {
|
||||
return err
|
||||
return fmt.Errorf("%w: %s", err, signatureHint)
|
||||
}
|
||||
fs.Errorf(nil, "protondrive: %q (ID %s): %v", r.n.Name, r.n.ID, err)
|
||||
return nil
|
||||
|
||||
@@ -229,6 +229,7 @@ func TestDownloadContentKey(t *testing.T) {
|
||||
data, err := readRange(t, c, getTestNode(t, c, id), 0, -1)
|
||||
if !tc.ok {
|
||||
require.ErrorIs(t, err, errIntegrity)
|
||||
assert.Contains(t, err.Error(), "ignore_signature_errors")
|
||||
data, err = readRange(t, ignoring, getTestNode(t, ignoring, id), 0, -1)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
@@ -282,6 +283,7 @@ func TestDownloadBadManifest(t *testing.T) {
|
||||
|
||||
data, err := readRange(t, c, n, 0, -1)
|
||||
require.ErrorIs(t, err, errIntegrity)
|
||||
assert.Contains(t, err.Error(), "ignore_signature_errors")
|
||||
assert.True(t, bytes.Equal(content, data), "the bytes come before the verdict")
|
||||
|
||||
// A ranged read can't check the manifest.
|
||||
|
||||
Reference in new issue
Block a user