mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-12-27 20:48:39 +01:00
Serve repository over HTTPS
This commit is contained in:
parent
7759264b37
commit
7d1de23ea9
@ -3748,12 +3748,12 @@ class SidebandApp(MDApp):
|
|||||||
|
|
||||||
ips = getIP()
|
ips = getIP()
|
||||||
if ips == None or len(ips) == 0:
|
if ips == None or len(ips) == 0:
|
||||||
info += "The repository server is running, but the local device IP address could not be determined.\n\nYou can access the repository by pointing a browser to: http://DEVICE_IP:4444/"
|
info += "The repository server is running, but the local device IP address could not be determined.\n\nYou can access the repository by pointing a browser to: https://DEVICE_IP:4444/"
|
||||||
self.reposository_url = None
|
self.reposository_url = None
|
||||||
else:
|
else:
|
||||||
ipstr = ""
|
ipstr = ""
|
||||||
for ip in ips:
|
for ip in ips:
|
||||||
ipstr += "http://"+str(ip)+":4444/\n"
|
ipstr += "https://"+str(ip)+":4444/\n"
|
||||||
self.reposository_url = ipstr
|
self.reposository_url = ipstr
|
||||||
|
|
||||||
ms = "" if len(ips) == 1 else "es"
|
ms = "" if len(ips) == 1 else "es"
|
||||||
|
@ -239,6 +239,9 @@ class SidebandCore():
|
|||||||
else:
|
else:
|
||||||
sideband_dir = os.path.dirname(os.path.abspath(__file__))
|
sideband_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
self.webshare_dir = os.path.abspath(os.path.join(sideband_dir, "..", "share"))
|
self.webshare_dir = os.path.abspath(os.path.join(sideband_dir, "..", "share"))
|
||||||
|
|
||||||
|
self.webshare_ssl_key_path = self.app_dir+"/app_storage/ssl_key.pem"
|
||||||
|
self.webshare_ssl_cert_path = self.app_dir+"/app_storage/ssl_cert.pem"
|
||||||
|
|
||||||
self.first_run = True
|
self.first_run = True
|
||||||
self.saving_configuration = False
|
self.saving_configuration = False
|
||||||
@ -4674,6 +4677,7 @@ class SidebandCore():
|
|||||||
from http import server
|
from http import server
|
||||||
import socketserver
|
import socketserver
|
||||||
import json
|
import json
|
||||||
|
import ssl
|
||||||
|
|
||||||
webshare_dir = self.webshare_dir
|
webshare_dir = self.webshare_dir
|
||||||
port = 4444
|
port = 4444
|
||||||
@ -4721,7 +4725,17 @@ class SidebandCore():
|
|||||||
self.wfile.write(es.encode("utf-8"))
|
self.wfile.write(es.encode("utf-8"))
|
||||||
|
|
||||||
socketserver.TCPServer.allow_reuse_address = True
|
socketserver.TCPServer.allow_reuse_address = True
|
||||||
with socketserver.TCPServer(("", port), RequestHandler) as webserver:
|
class ThreadedHTTPServer(socketserver.ThreadingMixIn, server.HTTPServer):
|
||||||
|
daemon_threads = True
|
||||||
|
|
||||||
|
with ThreadedHTTPServer(("", port), RequestHandler) as webserver:
|
||||||
|
from sideband.certgen import ensure_certificate
|
||||||
|
|
||||||
|
ensure_certificate(self.webshare_ssl_key_path, self.webshare_ssl_cert_path)
|
||||||
|
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
||||||
|
ssl_context.load_cert_chain(certfile=self.webshare_ssl_cert_path, keyfile=self.webshare_ssl_key_path)
|
||||||
|
webserver.socket = ssl_context.wrap_socket(webserver.socket, do_handshake_on_connect=False, server_side=True)
|
||||||
|
|
||||||
self.webshare_server = webserver
|
self.webshare_server = webserver
|
||||||
webserver.serve_forever()
|
webserver.serve_forever()
|
||||||
self.webshare_server = None
|
self.webshare_server = None
|
||||||
|
Loading…
Reference in New Issue
Block a user