import ssl
import http.client as client
import urllib.parse as parse
+import socket
import logging
log = logging.getLogger('pyi2ncommon.web_interface')
from .arnied_wrapper import accept_licence
+#: FQDN of local machine
+LOCALHOST = socket.gethostname()
+
def find_in_form(regex, form="status", escape=False, check_certs=True):
"""
implications!) by setting `check_certs` to `False`. To allow a secure
connection to host with e.g. a self-signed certificate, the caller can
load this certificate by specifying `check_certs=/path/to/cert.pem`.
- (see also: :py:meth:`ssl.SSLContext.load_verify_locations`)
+ (see also: :py:meth:`ssl.SSLContext.load_verify_locations`). Note that the
+ certificate has to be issued for the same server name that we try to
+ access, i.e. :py:data:`LOCALHOST`.
:param str method: GET or POST method for the request
:param str url: url location within the remote host
else:
# disable certificate checks
context = ssl._create_unverified_context()
- conn = client.HTTPSConnection("localhost", context=context)
+ conn = client.HTTPSConnection(LOCALHOST, context=context)
conn.request(method, url, body, headers)
resp = conn.getresponse()
logging.info("Request status %s and response %s",