[Python] Pika connecting using SSL with no certificate file

Discussão em 'Python' iniciado por Stack, Março 4, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to use pika to connect to RabbitMQ using SSL (self signed).

    The problem is that the connect not failing if I do not give the certificate file to pika.

    This is my code:

    import pika
    import urllib

    connection = pika.BlockingConnection(pika.URLParameters("amqps://guest:guest@172.16.120.130:25585"))
    channel = connection.channel()

    channel.queue_declare(queue='hello')
    channel.basic_publish(exchange='',
    routing_key='hello',
    body='Hello World!')

    print(" [x] Sent 'Hello World!'")
    connection.close()


    And this is my rabbitmq.config:

    {tcp_listeners, []},
    {ssl_listeners, [25585]},
    {ssl_options, [{cacertfile, "/etc/rabbitmq/certs/cacert.pem"},
    {certfile, "/etc/rabbitmq/certs/cert.pem"},
    {keyfile, "/etc/rabbitmq/certs/key.pem"},
    {verify, verify_peer},
    {versions, ['tlsv1.2', 'tlsv1.1', 'tlsv1']},
    {fail_if_no_peer_cert, false}]},


    I have disabled TCP connection and enabled the SSL, why is the connection not failing?

    Continue reading...

Compartilhe esta Página