Read the statement by Michael Teeuw here.
How to disable SSL check in python Request
-
Hi, guys.
Hope i’m posting this on the right place.I’ll try to be as clear as possible.
I have a Home Assistant on the same raspberry pi as my Magic Mirror. And I use MMM-HASS module (https://github.com/aserramonner/MMM-HASS) to see the state of a few sensor on my Home Assistant (light, temperature, etc).
I use my Home Assistant with a DuckDNS dns (xxxxx.duckdns.org) with Lets Encrypt SSL and everything worked fine, until I changed my router.
My new router doesnt support a feature called NAT Loopback, that is:
If I am outside my LAN (for example acessing from may phone 4G) I can access my home assistant with xxx.duckdns.org.
But if I am INSIDE my LAN (for example from my PC) I can’t access with xxx.duckdns.org. I can only access it with the raspberry pi IP itself: 192.168.X.X.The thing is, these modules that integrate with home assistant with magic mirror (like MMM-HASS and MMM-homeassistant-sensors) expect a “host” variable.
Since the MagicMirror is inside my LAN I have to access it with 192.168.X.X, but since I have a SSL encryption for xxx.duckdns.org, the magic mirror module get the connection error: “Hostname/IP does not match certificate’s altnames: IP: 192.168.X.X is not in the cert’s list:”
With my old router I set the “host” variable to xxx.duckdns.org. But since my new router doesn’t have this “NAT Loopback” thing, I have to set my LAN IP.
The solution is: I have to set these modules so they doesnt check the SSL. The Python “Request” has this option: verify=False, as I saw here: https://stackoverflow.com/questions/15445981/how-do-i-disable-the-security-certificate-check-in-python-requests
But my knowledge in Python is null. So, can anyone help me setting this “verify=False” parameter in the PYthon HTTP Request?
I tried editing this file “~/MagicMirror/modules/MMM-HASS/node_helper.js”, but I couldnt edit it the right way. I assume it is around these lines of code:
request(get_options, function(error, response, body) { completed_requests++; if(config.debuglogging) { console.log(error); console.log(body); } outDevice[body.entity_id] = body.state; if (completed_requests == urls.length) { // All requests done for the device, process responses array // to retrieve all the states outDevice.label = device.deviceLabel; console.log(outDevice); callback(outDevice); } });
but I couldnt get it right.
I tried changing the “get_options” var fromvar get_options = { url: urls[i], json: true };
to
var get_options = { url: urls[i], json: true, verify: false };
but no success either.
Hope I made myself clear, and thanks in advance!