def get_connection(urls=None, connection_kwargs=None):
    """
    Retrieve kombu "Conection" class instance configured with all the correct
    options using values from the config and provided values.

    :param connection_kwargs: Any additional connection keyword arguments passed directly to the
                              Connection class constructor.
    :type connection_kwargs: ``dict``
    """
    urls = urls or get_messaging_urls()
    connection_kwargs = connection_kwargs or {}

    kwargs = {}

    ssl_kwargs = _get_ssl_kwargs(
        ssl=cfg.CONF.messaging.ssl,
        ssl_keyfile=cfg.CONF.messaging.ssl_keyfile,
        ssl_certfile=cfg.CONF.messaging.ssl_certfile,
        ssl_cert_reqs=cfg.CONF.messaging.ssl_cert_reqs,
        ssl_ca_certs=cfg.CONF.messaging.ssl_ca_certs,
        login_method=cfg.CONF.messaging.login_method,
    )

    # NOTE: "connection_kwargs" argument passed to this function has precedence over config values
    if len(ssl_kwargs) == 1 and ssl_kwargs["ssl"] is True:
        kwargs.update({"ssl": True})
    elif len(ssl_kwargs) >= 2:
        ssl_kwargs.pop("ssl")
        kwargs.update({"ssl": ssl_kwargs})

    kwargs["login_method"] = cfg.CONF.messaging.login_method

    kwargs.update(connection_kwargs)

    # NOTE: This line contains no secret values so it's OK to log it
    LOG.debug("Using SSL context for RabbitMQ connection: %s" % (ssl_kwargs))

    connection = Connection(urls, **kwargs)
    return connection

    Retrieve kombu "Conection" class instance configured with all the correct
    options using values from the config and provided values.

    :param connection_kwargs: Any additional connection keyword arguments passed directly to the
                              Connection class constructor.
    :type connection_kwargs: ``dict``
    
st2common/st2common/transport/utils.py