[#202] pkg/client: Fix signature check in object header getter
According to API object.Head response contains signature of object ID rather than signature of object header itself. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
dd19eb7eca
commit
9ceba98198
1 changed files with 8 additions and 5 deletions
|
@ -543,7 +543,10 @@ func (c *Client) getObjectHeaderV2(ctx context.Context, p *ObjectHeaderParams, o
|
||||||
return nil, errors.Wrapf(err, "could not verify %T", resp)
|
return nil, errors.Wrapf(err, "could not verify %T", resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
var hdr *v2object.Header
|
var (
|
||||||
|
hdr *v2object.Header
|
||||||
|
idSig *v2refs.Signature
|
||||||
|
)
|
||||||
|
|
||||||
switch v := resp.GetBody().GetHeaderPart().(type) {
|
switch v := resp.GetBody().GetHeaderPart().(type) {
|
||||||
case nil:
|
case nil:
|
||||||
|
@ -576,15 +579,14 @@ func (c *Client) getObjectHeaderV2(ctx context.Context, p *ObjectHeaderParams, o
|
||||||
}
|
}
|
||||||
|
|
||||||
hdr = hdrWithSig.GetHeader()
|
hdr = hdrWithSig.GetHeader()
|
||||||
|
idSig = hdrWithSig.GetSignature()
|
||||||
|
|
||||||
if err := signer.VerifyDataWithSource(
|
if err := signer.VerifyDataWithSource(
|
||||||
signature.StableMarshalerWrapper{
|
signature.StableMarshalerWrapper{
|
||||||
SM: hdrWithSig.GetHeader(),
|
SM: p.addr.ObjectID().ToV2(),
|
||||||
},
|
},
|
||||||
func() (key, sig []byte) {
|
func() (key, sig []byte) {
|
||||||
s := hdrWithSig.GetSignature()
|
return idSig.GetKey(), idSig.GetSign()
|
||||||
|
|
||||||
return s.GetKey(), s.GetSign()
|
|
||||||
},
|
},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, errors.Wrap(err, "incorrect object header signature")
|
return nil, errors.Wrap(err, "incorrect object header signature")
|
||||||
|
@ -595,6 +597,7 @@ func (c *Client) getObjectHeaderV2(ctx context.Context, p *ObjectHeaderParams, o
|
||||||
|
|
||||||
obj := new(v2object.Object)
|
obj := new(v2object.Object)
|
||||||
obj.SetHeader(hdr)
|
obj.SetHeader(hdr)
|
||||||
|
obj.SetSignature(idSig)
|
||||||
|
|
||||||
raw := object.NewRawFromV2(obj)
|
raw := object.NewRawFromV2(obj)
|
||||||
raw.SetID(p.addr.ObjectID())
|
raw.SetID(p.addr.ObjectID())
|
||||||
|
|
Loading…
Reference in a new issue