From 3a22b712ab10c68c3d5c4d318d343c88e3020a10 Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Fri, 9 Sep 2022 17:26:23 +0200 Subject: [PATCH 1/2] Fix deprecation of PROTOCOL_TLS --- check_http_json.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_http_json.py b/check_http_json.py index 67defed..699507a 100755 --- a/check_http_json.py +++ b/check_http_json.py @@ -542,7 +542,7 @@ def main(cliargs): if args.ssl: url = "https://%s" % args.host - context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) + context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) context.options |= ssl.OP_NO_SSLv2 context.options |= ssl.OP_NO_SSLv3 From 9f41fc491e06bde90dc44eb885b18bcfab258b12 Mon Sep 17 00:00:00 2001 From: Markus Opolka Date: Fri, 9 Sep 2022 17:28:35 +0200 Subject: [PATCH 2/2] Add CLI flag to change HTTP method --- check_http_json.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/check_http_json.py b/check_http_json.py index 699507a..d21b3a1 100755 --- a/check_http_json.py +++ b/check_http_json.py @@ -430,6 +430,8 @@ def parseArgs(args): help='remote host to query') parser.add_argument('-k', '--insecure', action='store_true', help='do not check server SSL certificate') + parser.add_argument('-X', '--request', dest='method', default='GET', choices=['GET', 'POST'], + help='Specifies a custom request method to use when communicating with the HTTP server') parser.add_argument('-V', '--version', action='store_true', help='print version of this plugin') parser.add_argument('--cacert', @@ -587,7 +589,7 @@ def main(cliargs): json_data = '' try: - req = urllib.request.Request(url) + req = urllib.request.Request(url, method=args.method) req.add_header("User-Agent", "check_http_json") if args.auth: authbytes = str(args.auth).encode()