53 lines
1.4 KiB
Python
53 lines
1.4 KiB
Python
import os
|
|
import webview
|
|
|
|
import os
|
|
import platform
|
|
import subprocess
|
|
|
|
def run_webview():
|
|
ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
|
|
ssl_context.load_cert_chain(certfile=cert_path, keyfile=key_path)
|
|
|
|
url = "https://localhost:5001/"
|
|
|
|
webview.create_window(
|
|
"Unlock Key",
|
|
url,
|
|
width=800,
|
|
height=800,
|
|
resizable=True,
|
|
confirm_close=True,
|
|
text_select=True,
|
|
frameless=False,
|
|
background_color="#FFFFFF",
|
|
)
|
|
|
|
webview.start()
|
|
|
|
if __name__ == "__main__":
|
|
dir = os.path.dirname(os.path.abspath(__file__))
|
|
ca_path = os.path.join(dir, "ca.pem")
|
|
ca_key_path = os.path.join(dir, "ca_key.pem")
|
|
cert_path = os.path.join(dir, "cert.pem")
|
|
key_path = os.path.join(dir, "key.pem")
|
|
|
|
if not os.path.exists(cert_path) or not os.path.exists(key_path) or not os.path.exists(ca_path) or not os.path.exists(ca_key_path) :
|
|
ca, cert, key = generate_ca_and_cert(ca_path, ca_key_path, cert_path, key_path)
|
|
|
|
system = platform.system()
|
|
if system == "Windows":
|
|
add_ca_windows(ca)
|
|
elif system == "Darwin":
|
|
add_ca_macos(ca)
|
|
elif system == "Linux":
|
|
add_ca_linux(ca)
|
|
else:
|
|
raise Exception("OS not supported")
|
|
|
|
print("Cert installed")
|
|
else:
|
|
print("Cert already exists")
|
|
|
|
run_webview()
|