From 608586e92d335b575130f30255d5b1e167d33e64 Mon Sep 17 00:00:00 2001 From: Gunny Patel Date: Sat, 20 Jun 2020 02:35:53 -0400 Subject: [PATCH 1/2] solarwinds: ability to turn off ssl verification --- Solarwinds/scripts/actionExecutor.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Solarwinds/scripts/actionExecutor.py b/Solarwinds/scripts/actionExecutor.py index 83f96ef..fd54969 100755 --- a/Solarwinds/scripts/actionExecutor.py +++ b/Solarwinds/scripts/actionExecutor.py @@ -17,6 +17,7 @@ parser.add_argument('-password', '--password', help='Password for Solarwinds user that can acknowledge alerts', required=False) parser.add_argument('-timeout', '--timeout', help='Timeout', required=False) +parser.add_argument('-verifySsl', '--verifySsl', help='Verify SSL certificate returned by server?', required=False) args = vars(parser.parse_args()) @@ -48,7 +49,7 @@ def acknowledge_solarwinds_alert(url, auth_token, object_id, comment): logging.warning("Acknowledgement details: " + content) response = requests.post(endpoint, data=content, headers={"Content-Type": "application/json"}, auth=auth_token, - timeout=timeout) + timeout=timeout, verify=verifySsl) if response.status_code < 299: logging.info(LOG_PREFIX + " Successfully executed at Solarwinds.") @@ -67,7 +68,7 @@ def close_solarwinds_alert(url, auth_token, object_id, comment): logging.warning("Close details: " + content) response = requests.post(endpoint, data=content, headers={"Content-Type": "application/json"}, auth=auth_token, - timeout=timeout) + timeout=timeout, verify=verifySsl) if response.status_code < 299: logging.info(LOG_PREFIX + " Successfully executed at Solarwinds.") @@ -88,7 +89,7 @@ def add_note_solarwinds_alert(url, auth_token, object_id, comment): logging.warning("Close details: " + content) response = requests.post(endpoint, data=content, headers={"Content-Type": "application/json"}, auth=auth_token, - timeout=timeout) + timeout=timeout, verify=verifySsl) if response.status_code < 299: logging.info(LOG_PREFIX + " Successfully executed at Solarwinds.") @@ -114,14 +115,21 @@ def main(): password = parse_field('password', True) url = parse_field('url', True) timeout = args['timeout'] + verifySsl = args['verifySsl'] if not timeout: timeout = 30000 else: timeout = int(timeout) + + if not verifySsl: + verifySsl = False + else: + verifySsl = False if verifySsl.lower() == "false" else True logging.debug("Username: " + username) logging.debug("Password: " + password) + logging.debug("VerifySSL: " + str(verifySsl)) auth_token = HTTPBasicAuth(username, password) From ca1e7d74c06e155851ba406ee4b8c81fb2924100 Mon Sep 17 00:00:00 2001 From: Ghanshyam Patel Date: Wed, 23 Nov 2022 11:28:00 -0500 Subject: [PATCH 2/2] default verifySsl to True This preserves existing behavior when the argument is not provided. --- Solarwinds/scripts/actionExecutor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Solarwinds/scripts/actionExecutor.py b/Solarwinds/scripts/actionExecutor.py index fd54969..2d2427e 100755 --- a/Solarwinds/scripts/actionExecutor.py +++ b/Solarwinds/scripts/actionExecutor.py @@ -123,7 +123,7 @@ def main(): timeout = int(timeout) if not verifySsl: - verifySsl = False + verifySsl = True else: verifySsl = False if verifySsl.lower() == "false" else True