jkaluza / odcs

Forked from odcs 6 years ago
Clone

5d175ad Allow using SSL with SNI headers in Celery broker URL.

Authored and Committed by jkaluza 5 years ago
    Allow using SSL with SNI headers in Celery broker URL.
    
    Although the Celery handles amqps using Kombu Python module,
    it does not do that correctly.
    
    When using "amqps://" protocol, Kombu uses SSLTransport which effectively
    sets the `amqp.Connection.ssl = True`. This enables SSL, but it does it
    in a way when we cannot set any other SSL options like client cert/key
    or for example SNI hostname which we want to use by default everytime.
    
    This is done in this commit:
    https://github.com/celery/kombu/commit/701672c2ba732883869a42f061a10dbfc8fe2f30
    
    To workaround this, we detect "amqps" in this commit and sets the `broker_use_ssl`.
    This allows us to set any SSL options like client cert/key or SNI header.
    The `broker_use_ssl` is directly passed to `amqp.Connection.ssl` which handles
    it. For more info see:
    
    http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-broker_use_ssl
    
    In the end, we change the `broker_url` protocol from "amqps" to "amqp", so
    the Celery does not override the `amps.Connection.ssl` with `True` in mentioned
    `SSLTransport`.