Forráskód Böngészése

Added logic for certificate checking

Michael Honkoop 3 hónapja
szülő
commit
1385ed064a

+ 8 - 2
plugins/edirectory_monitor/server_side_calls/special_agent_edirectory_monitor.py

@@ -2,6 +2,8 @@
 
 # -*- encoding: utf-8; py-indent-offset: 4 -*-
 
+# (c) Michael Honkoop <mhonkoop@comsolve.nl>
+
 # License: GNU General Public License v2
 
 from collections.abc import Iterator, Mapping, Sequence
@@ -12,15 +14,20 @@ from cmk.server_side_calls.v1 import HostConfig, SpecialAgentCommand, SpecialAge
 from cmk.server_side_calls.v1._utils import Secret
 
 class Params(BaseModel):
+    check_tls: bool | None = None
     user: str
     password: Secret
 
 def commands_function(params: Params, host_config: HostConfig) -> Iterator[SpecialAgentCommand]:
-    command_arguments: Sequence[str | Secret] = [
+    """Always use LDAPS for querying LDAP Server"""
+    command_arguments: list[str | Secret] = [
         "ldaps://" +  host_config.name + ":636",
         params.user,
         params.password.unsafe(),
     ]
+    if params.check_tls is not None and params.check_tls is True:
+        command_arguments += ["--verify_tls"]
+
     yield SpecialAgentCommand(command_arguments=command_arguments)
 
 special_agent_edirectory_monitor = SpecialAgentConfig(
@@ -28,4 +35,3 @@ special_agent_edirectory_monitor = SpecialAgentConfig(
     parameter_parser=Params.model_validate,
     commands_function=commands_function,
 )
-