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

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

我正在使用 Pyro 4.34、Python 2.7 和 Jython 2.7。

名称服务器。我可以像这样启动名称服务器:

pyro4-ns --key abc

Pyro 服务器。文档指出我可以在 Pyro 守护程序上设置 _pyroHmacKey 属性,但是 locateNS 方法因 NamingError cannot find Name Server 而失败。

查看 locateNS 的 API,我看到它有一个名为 hmac_key 的参数。如果我去掉 _pryoHmacKey 并改用那个 arg,Pyro 服务器可以正常启动。

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

客户端。文档指出我可以在 proxy:

上设置 _pyroHmacKey 属性
proxy = Pyro4.Proxy("PYRONAME:test")
proxy._pyroHmacKey = 'abc'

但是,第一次调用 proxy 上的方法失败并显示:

CommunicationError: cannot connect: hmac key config not symmetric

在 Pyro 服务器代码中,我从 Pyro 守护进程中删除了 _pyroHmacKey 属性,因为我假设它只需要在 Pyro4.locateNS() 的参数中指定。一旦我重新添加它,一切正常。

看起来 hmac 密钥需要出现在两个位置才能正常工作。

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