mirror of
https://github.com/markqvist/Sideband.git
synced 2024-12-24 23:19:28 -05:00
Serve repository over HTTPS
This commit is contained in:
parent
7759264b37
commit
7d1de23ea9
@ -3748,12 +3748,12 @@ class SidebandApp(MDApp):
|
||||
|
||||
ips = getIP()
|
||||
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
|
||||
else:
|
||||
ipstr = ""
|
||||
for ip in ips:
|
||||
ipstr += "http://"+str(ip)+":4444/\n"
|
||||
ipstr += "https://"+str(ip)+":4444/\n"
|
||||
self.reposository_url = ipstr
|
||||
|
||||
ms = "" if len(ips) == 1 else "es"
|
||||
|
@ -239,6 +239,9 @@ class SidebandCore():
|
||||
else:
|
||||
sideband_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
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.saving_configuration = False
|
||||
@ -4674,6 +4677,7 @@ class SidebandCore():
|
||||
from http import server
|
||||
import socketserver
|
||||
import json
|
||||
import ssl
|
||||
|
||||
webshare_dir = self.webshare_dir
|
||||
port = 4444
|
||||
@ -4721,7 +4725,17 @@ class SidebandCore():
|
||||
self.wfile.write(es.encode("utf-8"))
|
||||
|
||||
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
|
||||
webserver.serve_forever()
|
||||
self.webshare_server = None
|
||||
|
Loading…
Reference in New Issue
Block a user