napalm-logs icon indicating copy to clipboard operation
napalm-logs copied to clipboard

Clients do not reconnect after server restarts causing crypt issues

Open luke-orden opened this issue 8 years ago • 3 comments

If the server restarts after the client has connected, then the client is left with old crypto info:

Traceback (most recent call last):
  File "/home/luke/git/napalm-logs/test-listen.py", line 19, in <module>
    decrypted = napalm_logs.utils.decrypt(data, vk, pk)
  File "/home/luke/git/napalm-logs/napalm_logs/utils/__init__.py", line 77, in decrypt
    raise BadSignatureException('Signature was forged or corrupt')
napalm_logs.exceptions.BadSignatureException: Signature was forged or corrupt

Therefore we need to have the clients restart, or allow them to use the old crypo info (not ideal)

luke-orden avatar Apr 26 '17 10:04 luke-orden

I think this can be tackled together with https://github.com/napalm-automation/napalm-logs/issues/47, as the right way to notify the clients (and implicitly to be aware of what clients are connected and receiving messages) is to maintain the auth socket open. Currently that socket is closed immediately after exchanging the private and signing key exchange.

mirceaulinic avatar Apr 26 '17 10:04 mirceaulinic

Added auth keep alive in #87, however clients will still fail to decrypt the message and hit an exception if the restarted server sends a new message before the keepalive is sent.

luke-orden avatar Jul 03 '17 10:07 luke-orden

Probably the solution would be to send a notification to the clients before the auth process is stopped. If the auth process dies without proper shutdown, the clients should try to reconnect, the timeout interval being a random value in ms, increasing after every failed connect attempt.

mirceaulinic avatar Jul 28 '17 16:07 mirceaulinic