Search code examples
pythonpyro

Pyro - How to use HMac key with Name Server? CommunicationError: hmac key config not symmetric


I'm using Pyro 4.34, Python 2.7 and Jython 2.7.

NameServer. I can start the name server like this fine:

pyro4-ns --key abc

Pyro Server. The documentation states that I can set the _pyroHmacKey attribute on the Pyro daemon, but the locateNS method failed with a NamingError cannot find Name Server.

Looking at the API for locateNS, I see that it has an arg called hmac_key. If I get rid of the _pryoHmacKey and use that arg instead, the Pyro Server can start fine.

name_server = Pyro4.locateNS(hmac_key='abc')

Client. The documentation states that I can set the _pyroHmacKey attribute on the proxy:

proxy = Pyro4.Proxy("PYRONAME:test")
proxy._pyroHmacKey = 'abc'

However, the first call to a method on proxy fails with:

CommunicationError: cannot connect: hmac key config not symmetric

Solution

  • In the Pyro Server code, I removed the _pyroHmacKey attribtue from the Pyro daemon because I assumed that it only needed to be specified in the parameter to Pyro4.locateNS(). Once I added it back in, everything worked.

    It looks like the hmac key needs to occur in both locations for everything to work.

    name_server = Pyro4.locateNS(hmac_key='abc')
    daemon = Pyro4.daemon()
    daemon._pyroHmacKey = 'abc'
    uri = daemon.register(Foo())
    ns.register('test, uri)
    daemon.requestLoop()