diff --git a/lemur/certificates/service.py b/lemur/certificates/service.py index 9337e356f..a7560f534 100644 --- a/lemur/certificates/service.py +++ b/lemur/certificates/service.py @@ -322,13 +322,17 @@ def get_certificates_with_same_cn_with_rotate_on(cn, date_created): date_created_max = date_created.ceil('day') query = database.session_query(Certificate)\ - .filter(Certificate.cn.like(cn))\ .filter(Certificate.rotation == true())\ .filter(Certificate.not_after >= now)\ .filter(Certificate.date_created >= date_created_min)\ .filter(Certificate.date_created <= date_created_max)\ .filter(not_(Certificate.replaced.any())) + if cn is not None: + query = query.filter(Certificate.cn.like(cn)) + else: + query = query.filter(Certificate.cn.is_(None)) + return query.all()