Hello,
i tried to utilize the mechanism regarding x.509 certificate to authenticate server and client. This was tested against RabbitMQ 3.8, python 3.5 and pika 1.0.
The Python Code:
import pika
import ssl
context = ssl.create_default_context(cafile = "C:/Users/chen/Desktop/CA/ca/root-cert.cer")
context.load_cert_chain("C:/Users/chen/Desktop/CA/client/client-cert.cer",
"C:/Users/chen/Desktop/CA/client/client-key.pem")
ssl_options = pika.SSLOptions(context, "localhost")
conn_params = pika.ConnectionParameters(port = 5671, ssl_options = ssl_options)
connection = pika.BlockingConnection(conn_params)
channel = connection.channel()
channel.queue_declare(queue= 'mmi.news', durable = True, arguments = {'x-queue-type':'classic'})
channel.basic_publish(exchange= 'exchange.direct', routing_key= 'mmi.news', body = 'test11')
connection.close()
And the Setting in rabbitmq config file:
[
{rabbit, [
{ssl_listeners, [5671]},
{auth_mechanisms, ['PLAIN','EXTERNAL']},
{ssl_options, [{cacertfile, "C:/Users/chen/Desktop/CA/ca/root-cert.cer"},
{certfile, "C:/Users/chen/Desktop/CA/server/server-cert.cer"},
{keyfile,"C:/Users/chen/Desktop/CA/server/server-key.pem" },
{verify, verify_peer},
{fail_if_no_peer_cert, false}]}
]}
].
After running a error was displayed: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646)
Does someone have a idea, what is the reason?
Kinds Regards
Jiahang Chen