diff --git a/management/pgp.py b/management/pgp.py index 23dfee1..5b4da0e 100755 --- a/management/pgp.py +++ b/management/pgp.py @@ -31,7 +31,7 @@ def key_representation(key): "auth": skey.can_authenticate == 1, "fpr": skey.fpr, "expires": skey.expires if skey.expires != 0 else None, - "expires_date": datetime.datetime.utcfromtimestamp(skey.expires).strftime("%x") if skey.expires != 0 else None, + "expires_date": datetime.datetime.utcfromtimestamp(skey.expires).date().isoformat() if skey.expires != 0 else None, "expires_days": (datetime.datetime.utcfromtimestamp(skey.expires) - now).days if skey.expires != 0 else None, "expired": skey.expired == 1, "algorithm": gpg.core.pubkey_algo_name(skey.pubkey_algo), @@ -101,9 +101,9 @@ def create_signature(data, detached=False): if __name__ == "__main__": import sys, utils # Check if we should renew the key - + daemon_key = get_daemon_key() - + exp = daemon_key.subkeys[0].expires now = datetime.datetime.utcnow() days_left = (datetime.datetime.utcfromtimestamp(exp) - now).days diff --git a/management/status_checks.py b/management/status_checks.py index e4632d7..a3de778 100755 --- a/management/status_checks.py +++ b/management/status_checks.py @@ -290,10 +290,10 @@ def run_pgp_checks(env, output): else: exp = datetime.datetime.utcfromtimestamp(sk.expires) # Our daemon key only has one subkey if (exp - now).days < 10 and sk.expires != 0: - output.print_warning(f"The daemon's key ({k.fpr}) will expire soon, in {(exp - now).days} days on {exp.strftime('%x')}.") + output.print_warning(f"The daemon's key ({k.fpr}) will expire soon, in {(exp - now).days} days on {exp.date().soformat()}.") else: - output.print_ok(f"The daemon's key ({k.fpr}) is good. It expires in {(exp - now).days} days on {exp.strftime('%x')}.") - + output.print_ok(f"The daemon's key ({k.fpr}) is good. It expires in {(exp - now).days} days on {exp.date().isoformat()}.") + # Check imported keys keys = get_imported_keys() if len(keys) == 0: @@ -313,7 +313,7 @@ def run_pgp_checks(env, output): expired.append((key, skey)) elif (exp - now).days < 10 and skey.expires != 0: about_to_expire.append((key, skey)) - + all_good = True def printpair(keytuple): key, skey = keytuple @@ -333,7 +333,7 @@ def run_pgp_checks(env, output): all_good = False output.print_error(f"There {'is 1 revoked key' if len(revoked) == 1 else f'are {len(revoked)} revoked keys'}.") list(map(lambda k: output.print_line(k.fpr), revoked)) - + if all_good: output.print_ok("All imported keys are good.")