ignore rotated certs, since there is a new cert that can be used

This commit is contained in:
Hossein Shafagh 2020-10-26 18:34:21 -07:00
parent 6a1b4b4857
commit 1ef6139f9b
1 changed files with 3 additions and 0 deletions

View File

@ -567,6 +567,7 @@ def query_common_name(common_name, args):
result = ( result = (
Certificate.query.filter(Certificate.not_after >= current_time.format("YYYY-MM-DD")) Certificate.query.filter(Certificate.not_after >= current_time.format("YYYY-MM-DD"))
.filter(not_(Certificate.revoked)) .filter(not_(Certificate.revoked))
.filter(not_(Certificate.replaced.any())) # ignore rotated certificates to avoid duplicates
.all() .all()
) )
elif common_name == "%": elif common_name == "%":
@ -575,6 +576,7 @@ def query_common_name(common_name, args):
Certificate.query.filter(Certificate.not_after >= current_time.format("YYYY-MM-DD")) Certificate.query.filter(Certificate.not_after >= current_time.format("YYYY-MM-DD"))
.filter(Certificate.owner == owner) .filter(Certificate.owner == owner)
.filter(not_(Certificate.revoked)) .filter(not_(Certificate.revoked))
.filter(not_(Certificate.replaced.any())) # ignore rotated certificates to avoid duplicates
.all() .all()
) )
else: else:
@ -584,6 +586,7 @@ def query_common_name(common_name, args):
.filter(Certificate.cn.like(common_name)) .filter(Certificate.cn.like(common_name))
.filter(Certificate.owner == owner) .filter(Certificate.owner == owner)
.filter(not_(Certificate.revoked)) .filter(not_(Certificate.revoked))
.filter(not_(Certificate.replaced.any())) # ignore rotated certificates to avoid duplicates
.all() .all()
) )