[#645] client/cache: Check response public key in all client operations
There is a need to check if public key in the RPC response matches the public key of the related storage node declared in network map. Define `ErrWrongPublicKey` error. Implement RPC response handler's constructor `AssertKeyResponseCallback` which checks public key. Construct handler and pass it to client's option `WithResponseInfoHandler`. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
78e4a87dca
commit
4661f65975
9 changed files with 90 additions and 12 deletions
4
pkg/network/cache/client.go
vendored
4
pkg/network/cache/client.go
vendored
|
@ -62,7 +62,9 @@ func (c *ClientCache) Get(info clientcore.NodeInfo) (client.Client, error) {
|
|||
return cli, nil
|
||||
}
|
||||
|
||||
cli := newMultiClient(netAddr, c.opts)
|
||||
cli := newMultiClient(netAddr, append(c.opts,
|
||||
client.WithResponseInfoHandler(clientcore.AssertKeyResponseCallback(info.PublicKey())),
|
||||
))
|
||||
|
||||
c.clients[cacheKey] = cli
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue