Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,71 +1,78 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import sys
|
| 3 |
-
import gradio as gr
|
| 4 |
-
from main import main
|
| 5 |
-
|
| 6 |
-
def gen_ssl(i_domains, wildcard, email, ca_server, key_type, key_size=None, key_curve=None):
|
| 7 |
-
if key_type == "rsa":
|
| 8 |
-
key_curve = None
|
| 9 |
-
elif key_type == "ecc":
|
| 10 |
-
key_size = None
|
| 11 |
-
else:
|
| 12 |
-
key_curve = None
|
| 13 |
-
if key_size is not None:
|
| 14 |
-
key_size = int(key_size)
|
| 15 |
-
|
| 16 |
-
print("
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from main import main
|
| 5 |
+
|
| 6 |
+
def gen_ssl(i_domains, wildcard, email, ca_server, key_type, key_size=None, key_curve=None):
|
| 7 |
+
if key_type == "rsa":
|
| 8 |
+
key_curve = None
|
| 9 |
+
elif key_type == "ecc":
|
| 10 |
+
key_size = None
|
| 11 |
+
else:
|
| 12 |
+
key_curve = None
|
| 13 |
+
if key_size is not None:
|
| 14 |
+
key_size = int(key_size)
|
| 15 |
+
print(f"Domains {i_domains}")
|
| 16 |
+
print(f"wildcard {wildcard}")
|
| 17 |
+
print(f"email {email}")
|
| 18 |
+
print(f"ca server {ca_server}")
|
| 19 |
+
print(f"keytype {key_type}")
|
| 20 |
+
print(f"keysize {key_size}")
|
| 21 |
+
print(f"keycurve {key_curve}")
|
| 22 |
+
pvt, csr, cert, email_status = main(i_domains, wildcard, email, ca_server, key_type, key_size, key_curve)
|
| 23 |
+
print("SSL Certificate generated successfully")
|
| 24 |
+
try:
|
| 25 |
+
return pvt.decode('utf-8'), csr.decode('utf-8'), cert.decode('utf-8'), email_status
|
| 26 |
+
except:
|
| 27 |
+
return pvt, csr, cert, email_status
|
| 28 |
+
|
| 29 |
+
def update_key_options(key_type):
|
| 30 |
+
if key_type == "rsa":
|
| 31 |
+
return gr.update(visible=True), gr.update(visible=False)
|
| 32 |
+
else:
|
| 33 |
+
return gr.update(visible=False), gr.update(visible=True)
|
| 34 |
+
|
| 35 |
+
def update_ca_server(wildcard: bool):
|
| 36 |
+
if wildcard == False:
|
| 37 |
+
return gr.update(choices=["Let's Encrypt (Testing)","Let's Encrypt", "Buypass (Testing)", "Buypass", "ZeroSSL", "Google (Testing)","Google", "SSL.com"], value="Let's Encrypt (Testing)")
|
| 38 |
+
else:
|
| 39 |
+
return gr.update(choices=["Let's Encrypt (Testing)","Let's Encrypt", "ZeroSSL", "Google (Testing)","Google", "SSL.com"], value="Let's Encrypt")
|
| 40 |
+
|
| 41 |
+
def update_buypass_options(ca_server):
|
| 42 |
+
if ca_server == "Buypass (Testing)" or ca_server == "Buypass":
|
| 43 |
+
return gr.update(choices=['SECP256R1'])
|
| 44 |
+
else:
|
| 45 |
+
return gr.update(choices=['SECP256R1', 'SECP384R1'])
|
| 46 |
+
|
| 47 |
+
def app():
|
| 48 |
+
with gr.Blocks(title="Project Gatekeeper - Get free SSL Certificates") as webui:
|
| 49 |
+
with gr.Row():
|
| 50 |
+
with gr.Column():
|
| 51 |
+
domains_input = gr.Textbox(label="Enter Domains", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
|
| 52 |
+
wildcard = gr.Checkbox(label="Wildcard SSL", interactive=True, value=False)
|
| 53 |
+
email_input = gr.Textbox(label="Enter your Email ID", placeholder="nayankasturi@gmail.com", type="text", interactive=True)
|
| 54 |
+
with gr.Row():
|
| 55 |
+
ca_server = gr.Dropdown(label="Select Certificate Authority", choices=["Let's Encrypt (Testing)","Let's Encrypt", "Google (Testing)","Google", "Buypass (Testing)", "Buypass", "ZeroSSL", "SSL.com"], interactive=True, value="Let's Encrypt (Testing)")
|
| 56 |
+
key_type = gr.Radio(label="Select SSL key type", choices=["rsa", "ecc"], interactive=True, value='ecc')
|
| 57 |
+
key_size_dropdown = gr.Dropdown(label="Select Key Size", choices=['2048', '4096'], value='4096', visible=False) # Initially visible
|
| 58 |
+
key_curve_dropdown = gr.Dropdown(label="Select Key Curve", choices=['SECP256R1', 'SECP384R1'], value='SECP256R1', visible=True) # Initially hidden
|
| 59 |
+
ca_server.change(fn=update_buypass_options, inputs=ca_server, outputs=key_curve_dropdown)
|
| 60 |
+
key_type.change(fn=update_key_options, inputs=key_type, outputs=[key_size_dropdown, key_curve_dropdown])
|
| 61 |
+
wildcard.change(fn=update_ca_server, inputs=wildcard, outputs=ca_server)
|
| 62 |
+
btn = gr.Button(value="Generate SSL Certificate")
|
| 63 |
+
with gr.Row():
|
| 64 |
+
with gr.Column():
|
| 65 |
+
pvt = gr.Textbox(label="Your Private Key", placeholder="Your Private Key will appear here, after successful SSL generation", type="text", interactive=False, show_copy_button=True, lines=10, max_lines=10)
|
| 66 |
+
with gr.Column():
|
| 67 |
+
csr = gr.Textbox(label="Your CSR", placeholder="Your CSR will appear here, after successful SSL generation", type="text", interactive=False, show_copy_button=True, lines=10, max_lines=10)
|
| 68 |
+
with gr.Column():
|
| 69 |
+
crt = gr.Textbox(label="Your SSL Certificate", placeholder="Your SSL Certificate will appear here, after successful SSL generation", type="text", interactive=False, show_copy_button=True, lines=10, max_lines=10)
|
| 70 |
+
email_status = gr.Textbox(label="Email Status", placeholder="Email status will appear here, after sending email", type="text", interactive=False)
|
| 71 |
+
btn.click(gen_ssl, inputs=[domains_input, wildcard, email_input, ca_server, key_type, key_size_dropdown, key_curve_dropdown], outputs=[pvt, csr, crt, email_status])
|
| 72 |
+
try:
|
| 73 |
+
webui.queue(default_concurrency_limit=15).launch()
|
| 74 |
+
except Exception as e:
|
| 75 |
+
print(f"Error: {e}")
|
| 76 |
+
|
| 77 |
+
if __name__ == "__main__":
|
| 78 |
+
app()
|