Match date format for comparison + expected new lines

This commit is contained in:
sayali 2020-09-01 12:44:49 -07:00
parent db4f68f0ed
commit 8ad4448c85
1 changed files with 3 additions and 1 deletions

View File

@ -131,7 +131,7 @@ def map_fields(options, csr):
elif options.get("validity_end"): elif options.get("validity_end"):
data["custom_expiration_date"] = determine_end_date(options.get("validity_end")).format("YYYY-MM-DD") data["custom_expiration_date"] = determine_end_date(options.get("validity_end")).format("YYYY-MM-DD")
# check if validity got truncated. If resultant validity is not equal to requested validity, it just got truncated # check if validity got truncated. If resultant validity is not equal to requested validity, it just got truncated
if data["custom_expiration_date"] != options.get("validity_end"): if data["custom_expiration_date"] != options.get("validity_end").format("YYYY-MM-DD"):
log_validity_truncation(options, f"{__name__}.{sys._getframe().f_code.co_name}") log_validity_truncation(options, f"{__name__}.{sys._getframe().f_code.co_name}")
else: else:
data["validity_years"] = determine_validity_years(0) data["validity_years"] = determine_validity_years(0)
@ -185,6 +185,7 @@ def map_cis_fields(options, csr):
return data return data
def log_validity_truncation(options, function): def log_validity_truncation(options, function):
log_data = { log_data = {
"cn": options["common_name"], "cn": options["common_name"],
@ -196,6 +197,7 @@ def log_validity_truncation(options, function):
log_data["message"] = "Digicert Plugin truncated the validity of certificate, cn = {0}".format(options["common_name"]) log_data["message"] = "Digicert Plugin truncated the validity of certificate, cn = {0}".format(options["common_name"])
current_app.logger.info(log_data) current_app.logger.info(log_data)
def handle_response(response): def handle_response(response):
""" """
Handle the DigiCert API response and any errors it might have experienced. Handle the DigiCert API response and any errors it might have experienced.