def attach_certificate(name, port, certificate_id, **kwargs):
    """
    Attaches a certificate to a listener, throws exception
    if certificate specified does not exist in a particular account.

    :param name:
    :param port:
    :param certificate_id:
    """
    try:
        return kwargs["client"].set_load_balancer_listener_ssl_certificate(
            LoadBalancerName=name,
            LoadBalancerPort=port,
            SSLCertificateId=certificate_id,
        )
    except botocore.exceptions.ClientError as e:
        if e.response["Error"]["Code"] == "LoadBalancerNotFound":
            current_app.logger.warning("Loadbalancer does not exist.")
        else:
            raise e

    Attaches a certificate to a listener, throws exception
    if certificate specified does not exist in a particular account.

    :param name:
    :param port:
    :param certificate_id:
    
lemur/plugins/lemur_aws/elb.py