From 88d12eb88f5f4bb0098f6204a91059dea06e53f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Wed, 22 Mar 2023 15:19:36 +0100 Subject: [PATCH] [issue-4] [add] parameter:port --- source/localization/de.json | 2 +- source/logic/checks/tls_certificate.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/localization/de.json b/source/localization/de.json index 692a1cd..f650cdb 100644 --- a/source/localization/de.json +++ b/source/localization/de.json @@ -17,7 +17,7 @@ "checks.file_state.timestamp_implausible": "Datei ist scheinbar aus der Zukunft", "checks.file_state.too_old": "Datei ist zu alt", "checks.file_state.too_big": "Datei ist zu groß", - "checks.tls_certificate.not_obtainable": "TLS-Zertifikat nicht abrufbar; evtl. bereits augelaufen", + "checks.tls_certificate.not_obtainable": "TLS-Zertifikat nicht abrufbar; evtl. bereits ausgelaufen", "checks.tls_certificate.expires_soon": "TLS-Zertifikat läuft bald aus", "checks.generic_remote.overflow": "Laufwerk fast voll", "checks.http_request.request_failed": "HTTP-Abfrage fehlgeschlagen", diff --git a/source/logic/checks/tls_certificate.py b/source/logic/checks/tls_certificate.py index 007a658..0548f07 100644 --- a/source/logic/checks/tls_certificate.py +++ b/source/logic/checks/tls_certificate.py @@ -1,6 +1,7 @@ ''' todo: allow_self_signed todo: allow_bad_domain +todo: ''' class implementation_check_kind_tls_certificate(interface_check_kind): @@ -15,6 +16,10 @@ class implementation_check_kind_tls_certificate(interface_check_kind): "host": { "type": "string" }, + "port": { + "type": "integer", + "default": 443 + }, "strict": { "description": "whether a violation of this check shall be leveled as critical instead of concerning", "type": "boolean", @@ -43,6 +48,7 @@ class implementation_check_kind_tls_certificate(interface_check_kind): return dict_merge( { "strict": True, + "port": 443, "expiry_threshold": 7, # "allow_self_signed": False, # "allow_bad_domain": False, @@ -58,7 +64,7 @@ class implementation_check_kind_tls_certificate(interface_check_kind): def run(self, parameters): context = _ssl.create_default_context() try: - socket = _socket.create_connection((parameters["host"], 443, )) + socket = _socket.create_connection((parameters["host"], parameters["port"], )) socket_wrapped = context.wrap_socket(socket, server_hostname = parameters["host"]) version = socket_wrapped.version() data = socket_wrapped.getpeercert(False) @@ -74,6 +80,7 @@ class implementation_check_kind_tls_certificate(interface_check_kind): ), "info": { "host": parameters["host"], + "port": parameters["port"], "faults": [ translation_get("checks.tls_certificate.not_obtainable"), ], @@ -95,6 +102,7 @@ class implementation_check_kind_tls_certificate(interface_check_kind): ), "info": { "host": parameters["host"], + "port": parameters["port"], "faults": [ translation_get("checks.tls_certificate.expires_soon"), ],