stanvit / nagios-monit-plugin

Nagios plugin for monit state checking
MIT License
12 stars 5 forks source link

Idea: Possibility to disable SSL certificate checking #7

Closed m0urs closed 6 years ago

m0urs commented 6 years ago

As I am using a self signed certificate for MONIT it would be great to have an option to disable certificate checking. I solved that by myself by adding the following lines to the beginning of the script:

try: _create_unverified_https_context = ssl._create_unverified_context except AttributeError:

Legacy Python that doesn't verify HTTPS certificates by default

pass

else:

Handle target environment that doesn't support HTTPS verification

ssl._create_default_https_context = _create_unverified_https_context
stanvit commented 6 years ago

Hi @m0urs, please check the change: new option -k or --insecure was added. Tested in Python 2.7.14 (MacOS), 2.7.9 (first release checking certs) and 2.7.8 (last one that doesn't).

m0urs commented 6 years ago

Hi @stanvit , that solves the issue. Thanks a lot!