check-mk-web-api icon indicating copy to clipboard operation
check-mk-web-api copied to clipboard

problem when using self signed ssl certs

Open pescobar opened this issue 4 years ago • 0 comments

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?

pescobar avatar May 20 '21 16:05 pescobar