In my current situation I am using the stomp.py library (http://jasonrbriggs.github.io/stomp.py/stomp.html#module-stomp.connect) to connect to an ActiveMQ instance on another server. I am on python 2.7 and the connection works just fine when no SSL is configured. I use provided connection method (1.2) to connect and provide the following parameters in addition to host and ports:
The key and cert files are text from said files which I got using the file open() method which seems to work fine.
I have tried among other options to also set the context in ssl.SSL_Context. I am quite sure the ActiveMQ uses SSL and has said protocol.
When I'm trying to connect using conn.start() I receive the following error:
File "/usr/local/lib/python2.7/dist-packages/stomp/transport.py", line 733, in attempt_connection
tls_context.load_cert_chain(certfile, keyfile, password)
IOError: [Errno 71] Protocol error
I am unable to find a working example on getting stomp.py to connect using SSL, so I cannot find a way to do this.
Is there anyone out there who has seen this before?
Found the answer myself after quite an extensive search. It turns out you need to set_ssl before.
conn.set_ssl(for_hosts=[(activemq_url,activemq_port)],key_file=KEYFILE,cert_file=CERTFILE)
Where KEYFILE and CERTFILE you need to provide a path where set_ssl can check for and pass in the contents using the file open() method.
Note: You need to set this after creating connection but before the conn.start() method is called!