brennerm / check-mk-web-api

Python library to talk to the Check_Mk Web API
https://brennerm.github.io/check-mk-web-api/
MIT License
53 stars 26 forks source link

problem when using self signed ssl certs #42

Open pescobar opened 3 years ago

pescobar commented 3 years ago

Hi,

I am testing in a check_mk installation with a self-signed SSL certificate and I was getting this error: raise URLError(err)urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897)>

The crash happens here : https://github.com/brennerm/check-mk-web-api/blob/master/check_mk_web_api/__init__.py#L142-L145

In a quick google search I found a possible workaround here

I did a test and this seems to work to skip ssl validation and be able to query self-signed certs:

        import ssl
        ctx = ssl.create_default_context()
        ctx.check_hostname = False
        ctx.verify_mode = ssl.CERT_NONE

        response = urllib.request.urlopen(
            self.__build_request_path(query_params),
            WebApi.__build_request_data(data, request_format),context=ctx
        )

Would it be possible to add an option to skip ssl validation when working with self-signed ssl certs?