From 1ba3b3785d6123aa40bf6e6646faf016035e0713 Mon Sep 17 00:00:00 2001 From: Plamen Dimitrov Date: Tue, 26 Mar 2019 11:53:52 +0800 Subject: [PATCH] Allow HTTPS connections with self-signed certificates We use such certificates on the web surface of the Intra2net system. --- src/web_interface.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) 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", -- 1.7.1