谁能解释一下如何将 SSL 添加到我正在使用的 Python STOMP 客户端。我在 ActiveMQ 配置文件中添加了 stomp+ssl 传输连接器,我的基本 Python STOMP 客户端如下:
import time
import sys
import stomp
class MyListener(stomp.ConnectionListener):
def on_error(self, headers, message):
print('received an error "%s"' % message)
def on_message(self, headers, message):
print('received a message "%s"' % message)
conn = stomp.Connection()
conn.set_listener('', MyListener())
conn.start()
conn.connect('admin', 'password', wait=True)
conn.subscribe(destination='/queue/test', id=1, ack='auto')
conn.send(body=' '.join(sys.argv[1:]), destination='/queue/test')
time.sleep(2)
conn.disconnect()
Run Code Online (Sandbox Code Playgroud)
我创建了http://activemq.apache.org/how-do-i-use-ssl.html文档中给出的密钥库和信任库,并将它们添加到SSL_OPTS代理中的环境变量中,但我找不到如何使用密钥库和信任库初始化 Python STOMP 客户端。我是否应该使用stomp.Connection()方法中给出的 SSL 参数,如果是,如何使用?
谁能解释一下是否还有其他方法可以通过 STOMP 添加 SSL?