def disable_rotation_of_duplicate_certificates():
    """
    We occasionally get duplicate certificates with Let's encrypt. Figure out the set of duplicate certificates and
    disable auto-rotate if no endpoint is attached to the certificate. This way only the certificate with endpoints
    will get auto-rotated. If none of the certs have endpoint attached, to be on the safe side, keep auto rotate ON
    for one of the certs. This task considers all the certificates issued by the authorities listed in the config
    AUTHORITY_TO_DISABLE_ROTATE_OF_DUPLICATE_CERTIFICATES
    Determining duplicate certificates: certificates sharing same name prefix (followed by serial number to make it
    unique) which have same validity length (issuance and expiration), owner, destination, SANs.
    :return:
    """

    function = f"{__name__}.{sys._getframe().f_code.co_name}"
    task_id = None
    if celery_app.current_task:
        task_id = celery_app.current_task.request.id

    log_data = {
        "function": function,
        "message": "Disable rotation of duplicate certs issued by Let's Encrypt",
        "task_id": task_id,
    }

    if task_id and is_task_active(function, task_id, None):
        log_data["message"] = "Skipping task: Task is already active"
        current_app.logger.debug(log_data)
        return

    current_app.logger.debug(log_data)
    try:
        cli_certificate.disable_rotation_of_duplicate_certificates(True)
    except SoftTimeLimitExceeded:
        log_data["message"] = "Time limit exceeded."
        current_app.logger.error(log_data)
        capture_exception()
        metrics.send("celery.timeout", "counter", 1, metric_tags={"function": function})
        return
    except Exception as e:
        current_app.logger.info(log_data)
        capture_exception()
        current_app.logger.exception(e)
        return

    metrics.send(f"{function}.success", "counter", 1)

    We occasionally get duplicate certificates with Let's encrypt. Figure out the set of duplicate certificates and
    disable auto-rotate if no endpoint is attached to the certificate. This way only the certificate with endpoints
    will get auto-rotated. If none of the certs have endpoint attached, to be on the safe side, keep auto rotate ON
    for one of the certs. This task considers all the certificates issued by the authorities listed in the config
    AUTHORITY_TO_DISABLE_ROTATE_OF_DUPLICATE_CERTIFICATES
    Determining duplicate certificates: certificates sharing same name prefix (followed by serial number to make it
    unique) which have same validity length (issuance and expiration), owner, destination, SANs.
    :return:
    
lemur/common/celery.py