1
0
mirror of https://github.com/moepman/acertmgr.git synced 2024-12-27 10:41:51 +01:00

logging: Add real counterparts of IDNA-mapped domains in brackets

This commit is contained in:
Kishi85 2021-09-15 14:38:01 +02:00 committed by Markus Hauschild
parent 460b0119ac
commit 6f0ccfdc91
2 changed files with 9 additions and 1 deletions

View File

@ -15,7 +15,7 @@ import sys
from acertmgr import configuration, tools
from acertmgr.authority import authority
from acertmgr.modes import challenge_handler
from acertmgr.tools import log
from acertmgr.tools import log, LOG_REPLACEMENTS
try:
import pwd
@ -139,6 +139,9 @@ def cert_revoke(cert, configs, fallback_authority, reason=None):
def main():
# load config
runtimeconfig, domainconfigs = configuration.load()
# register idna-mapped domains as LOG_REPLACEMENTS for better readability of log output
LOG_REPLACEMENTS.update({k: "{} [{}]".format(k, v) for k, v in domainconfigs['domainlist_idna_mapped']})
# Start processing
if runtimeconfig.get('mode') == 'revoke':
# Mode: revoke certificate
log("Revoking {}".format(runtimeconfig['revoke']))

View File

@ -38,6 +38,8 @@ try:
except ImportError:
from urllib2 import urlopen, Request # Python 2
LOG_REPLACEMENTS = {}
class InvalidCertificateError(Exception):
pass
@ -59,6 +61,9 @@ def log(msg, exc=None, error=False, warning=False):
prefix = ""
output = prefix + msg
for k, v in LOG_REPLACEMENTS.items():
output = output.replace(k, v)
if exc:
_, exc_value, _ = sys.exc_info()
if not getattr(exc, '__traceback__', None) and exc == exc_value: