Module: check_mk
Branch: master
Commit: a0de9801d9cb3306a590893407c55e14f9195006
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a0de9801d9cb33…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Mar 21 12:44:55 2019 +0100
7221 FIX check_http: proxy settings for cert check
Previously the proxy settings had been ignored when checking a
certificate unless the option "Check Certificate of different
IP / DNS Name" had been used.
Change-Id: I230a85eac649155749e73767ad8ac54e3bce8eb7
---
.werks/7221 | 12 ++++++++++++
checks/check_http | 24 +++++++++++-------------
tests/unit/checks/test_check_http.py | 2 +-
3 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/.werks/7221 b/.werks/7221
new file mode 100644
index 0000000..971717e
--- /dev/null
+++ b/.werks/7221
@@ -0,0 +1,12 @@
+Title: check_http: Use proxy settings for certificate check
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1553168564
+Class: fix
+
+Previously the proxy settings had been ignored when checking a certificate
+unless the option "Check Certificate of different IP / DNS Name" had been
used.
+
diff --git a/checks/check_http b/checks/check_http
index 3f5e9fe..b493b0d 100644
--- a/checks/check_http
+++ b/checks/check_http
@@ -46,19 +46,17 @@ def _get_family_and_address(settings):
def _certificate_args(address_family, address, settings):
args = []
- if "cert_host" in settings:
- if settings.get('proxy'):
- args += ['-I', settings['proxy']]
- args += ['-H', settings['cert_host']]
- args.append('--ssl')
- args += ['-j', 'CONNECT']
- elif settings.get("sni"):
- args += ['-H', settings['cert_host']]
- else:
- args += ['-I', settings['cert_host']]
- args += ['-H', address]
- else:
- args += ["-I", address]
+ server = settings.get('cert_host', address)
+ proxy = settings.get('proxy')
+
+ args += ['-I', proxy or server]
+
+ if proxy:
+ args += ['-H', server]
+ args.append('--ssl')
+ args += ['-j', 'CONNECT']
+ elif settings.get("sni"):
+ args += ['-H', server]
if address_family == 'ipv6':
args += ['-6']
diff --git a/tests/unit/checks/test_check_http.py b/tests/unit/checks/test_check_http.py
index e420a6d..f4c638d 100644
--- a/tests/unit/checks/test_check_http.py
+++ b/tests/unit/checks/test_check_http.py
@@ -35,7 +35,7 @@ pytestmark = pytest.mark.checks
'cert_days': (10, 20),
'cert_host': 'www.test123.com'
}),
- ['-I', 'www.test123.com', '-H',
'$_HOSTADDRESS_4$', '-C', '10,20'],
+ ['-I', 'www.test123.com', '-C', '10,20'],
)])
def test_check_http_argument_parsing(check_manager, params, expected_args):
"""Tests if all required arguments are present. The tests do not check
the order of arguments."""