From: Plamen Dimitrov Date: Tue, 26 Mar 2019 03:53:52 +0000 (+0800) Subject: Allow HTTPS connections with self-signed certificates X-Git-Tag: v1.5~3^2~3 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=1ba3b3785d6123aa40bf6e6646faf016035e0713;p=pyi2ncommon Allow HTTPS connections with self-signed certificates We use such certificates on the web surface of the Intra2net system. --- diff --git a/src/web_interface.py b/src/web_interface.py index 699d672..ddeb8da 100644 --- a/src/web_interface.py +++ b/src/web_interface.py @@ -33,6 +33,7 @@ INTERFACE """ import re +import ssl import http.client as client import urllib.parse as parse import logging @@ -76,7 +77,9 @@ def web_page_request(method="GET", url="/", body=None): headers = {"Content-Type": "application/x-www-form-urlencoded", "Accept": "text/plain"} - conn = client.HTTPSConnection("localhost") + # Allow for an HTTPS connection with self-signed certificates + context = ssl._create_unverified_context() + conn = client.HTTPSConnection("localhost", context=context) conn.request(method, url, body, headers) resp = conn.getresponse() logging.info("Request status %s and response %s",