mosquito / aio-pika

AMQP 0.9 client designed for asyncio and humans.
https://aio-pika.readthedocs.org/
Apache License 2.0
1.18k stars 186 forks source link

Extend docs + example for mtls-connection #479

Closed clane2812 closed 1 year ago

clane2812 commented 1 year ago

Hello, while connecting to a rabbit-mq with mtls and pika i had the topic that the example 'external-credentials.py' in the docs shows a correct tls-connections with certificate-validation on both-sides, but fails on the "last-step", when you want to authenticate with the client-cert and not addtitional user/pw-credentials (guest/guest in the example):

When the broker does not allow the authentication-method 'PLAIN' (or you don´t want to use it) you have to pass the 'auth'-parameter set to 'external' to the connect method (or in the ssl_options):

connection = await aio_pika.connect_robust(
    host="127.0.0.1",
    port = 1234,
    ssl=True,
    auth='external',
    ssl_options=dict(
        certfile="test.crt",
        keyfile="test.key",
        cert_reqs=ssl.CERT_REQUIRED,
    ),
    client_properties={"connection_name": "aio-pika external credentials"},
)

This parameter seems not to be documented in the API-reference. I found it debugging to the underlying layer in the aiormq-lib. Perhaps it would be helpful to document it in the connect_robust method or extend the example with some comments?