napalm-logs
napalm-logs copied to clipboard
Clients do not reconnect after server restarts causing crypt issues
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)
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.
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.
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.