예제 #1
0
def get_ssl_config():
    """
    Return the ssl config based on the configuration specified in the
    `app.yaml` config file.
    """
    broker = ""
    try:
        broker = CONFIG.broker.url.split(":")[0]
    except AttributeError:
        pass

    try:
        broker = CONFIG.broker.name.lower()
    except AttributeError:
        pass

    if broker not in BROKERS:
        return False

    try:
        certs_path = CONFIG.celery.certs
    except AttributeError:
        certs_path = None

    broker_ssl = get_ssl_entries("Broker", broker, CONFIG.broker, certs_path)

    if not broker_ssl:
        broker_ssl = True

    if broker == "rabbitmq" or broker == "rediss":
        return broker_ssl

    return False
예제 #2
0
def get_ssl_config(celery_check=False):
    """
    Return the ssl config based on the configuration specified in the
    `app.yaml` config file.

    :param celery_check : Return the proper results ssl setting when configuring celery
    """
    results_backend = ""
    try:
        results_backend = CONFIG.results_backend.url.split(":")[0]
    except AttributeError:
        pass

    try:
        results_backend = CONFIG.results_backend.name.lower()
    except AttributeError:
        pass

    if results_backend not in BACKENDS:
        return False

    try:
        certs_path = CONFIG.celery.certs
    except AttributeError:
        certs_path = None

    results_backend_ssl = get_ssl_entries(
        "Results Backend", results_backend, CONFIG.results_backend, certs_path
    )

    if results_backend == "rediss":
        if not results_backend_ssl:
            results_backend_ssl = True
        return results_backend_ssl

    if results_backend and "mysql" in results_backend:
        if not celery_check:
            return results_backend_ssl

    return False
예제 #3
0
def get_ssl_config() -> Union[bool, Dict[str, Union[str, ssl.VerifyMode]]]:
    """
    Return the ssl config based on the configuration specified in the
    `app.yaml` config file.

    :return: Returns either False if no ssl
    :rtype: Union[bool, Dict[str, Union[str, ssl.VerifyMode]]]
    """
    broker: Union[bool, str] = ""
    try:
        broker = CONFIG.broker.url.split(":")[0]
    except AttributeError:
        pass

    try:
        broker = CONFIG.broker.name.lower()
    except AttributeError:
        pass

    if broker not in BROKERS:
        return False

    certs_path: Optional[str]
    try:
        certs_path = CONFIG.celery.certs
    except AttributeError:
        certs_path = None

    broker_ssl: Union[bool,
                      Dict[str, Union[str, ssl.VerifyMode]]] = get_ssl_entries(
                          "Broker", broker, CONFIG.broker, certs_path)

    if not broker_ssl:
        broker_ssl = True

    if broker == "rabbitmq" or broker == "rediss" or broker == "amqps":
        return broker_ssl

    return False