Commits

William Pitcock  committed 465b501

rpc_server: provide friendly error on InvalidSignatureException

  • Participants
  • Parent commits b18536f

Comments (0)

Files changed (1)

File ediarpc/rpc_server.py

 
 import SocketServer
 import rpc_message
+from message import InvalidSignatureException
 
 class RPCRequestHandler(SocketServer.StreamRequestHandler):
     allow_reuse_address = True
         return self._error_message(404, "Method not implemented")
 
     def dispatch(self, envelope):
-        unpack_message = rpc_message.decode(self.secret, envelope)
+        try:
+            unpack_message = rpc_message.decode(self.secret, envelope)
+        except InvalidSignatureException:
+            return self._error_message(403, "Unauthorized, invalid passphrase")
+
         unpack_kwargs = unpack_message[1]
 
         if unpack_message[0] is None: