Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,101 +1,101 @@
|
|
1 |
-
import os
|
2 |
-
import sys
|
3 |
-
import gradio as gr
|
4 |
-
from main import main
|
5 |
-
from tools import write_file, get_domains
|
6 |
-
from gen_client_cnames import gen_client_cnames
|
7 |
-
from verify_cname import verify_cname
|
8 |
-
|
9 |
-
def gen_cname(i_domains):
|
10 |
-
cf_domain = "silerudaagartha.eu.org"
|
11 |
-
cname_recs, cname_values = gen_client_cnames(i_domains, cf_domain)
|
12 |
-
table_data = []
|
13 |
-
for rec, value in zip(cname_recs, cname_values):
|
14 |
-
table_data.append([rec, value])
|
15 |
-
return table_data
|
16 |
-
|
17 |
-
def check_cname(domains):
|
18 |
-
data = verify_cname(domains)
|
19 |
-
return data
|
20 |
-
|
21 |
-
def gen_ssl(i_domains, wildcard, email, ca_server, key_type, key_size=None, key_curve=None):
|
22 |
-
if key_type == "rsa":
|
23 |
-
key_curve = None
|
24 |
-
elif key_type == "ec":
|
25 |
-
key_size = None
|
26 |
-
else:
|
27 |
-
key_curve = None
|
28 |
-
if key_size is not None:
|
29 |
-
key_size = int(key_size)
|
30 |
-
pvt, csr, cert = main(i_domains, wildcard, email, ca_server, key_type, key_size, key_curve)
|
31 |
-
path = email.split("@")[0]
|
32 |
-
os.makedirs(path, exist_ok=True)
|
33 |
-
write_file(f"{path}/private.pem", pvt)
|
34 |
-
write_file(f"{path}/domain.csr", csr)
|
35 |
-
write_file(f"{path}/cert.pem", cert)
|
36 |
-
return pvt, f"{path}/private.pem", csr, f"{path}/domain.csr", cert, f"{path}/cert.pem"
|
37 |
-
|
38 |
-
def update_key_options(key_type):
|
39 |
-
if key_type == "rsa":
|
40 |
-
return gr.update(visible=True), gr.update(visible=False)
|
41 |
-
else:
|
42 |
-
return gr.update(visible=False), gr.update(visible=True)
|
43 |
-
|
44 |
-
def update_ca_server(wildcard: bool):
|
45 |
-
if wildcard == False:
|
46 |
-
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)")
|
47 |
-
else:
|
48 |
-
return gr.update(choices=["Let's Encrypt (Testing)","Let's Encrypt", "ZeroSSL", "Google (Testing)","Google", "SSL.com"], value="Let's Encrypt")
|
49 |
-
|
50 |
-
def app():
|
51 |
-
with gr.Blocks(title="Project Gatekeeper - Get free SSL Certificates") as webui:
|
52 |
-
with gr.Tab("STEP 1: Generate CNAME Records"):
|
53 |
-
with gr.Row():
|
54 |
-
cname_domains = gr.Textbox(value="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", label="Enter Domains", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
|
55 |
-
btn1 = gr.Button(value="Generate CNAME Records & Values")
|
56 |
-
with gr.Row():
|
57 |
-
records = gr.Dataframe(label="CNAME Records", headers=["CNAME", "CNAME VALUE"], row_count=(1), col_count=(2))
|
58 |
-
btn1.click(gen_cname, inputs=cname_domains, outputs=records)
|
59 |
-
with gr.Tab("STEP 2: Check CNAME Propagation"):
|
60 |
-
with gr.Row():
|
61 |
-
check_domains = gr.Textbox(label="Enter CNAME", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
|
62 |
-
btn2 = gr.Button(value="Check CNAME Propagation")
|
63 |
-
with gr.Row():
|
64 |
-
data = gr.Dataframe(label="CNAME Records", headers=["CNAME", "Expected CNAME Value", "Found CNAME Value", "CNAME Status"], row_count=(1), col_count=(4))
|
65 |
-
btn2.click(verify_cname, inputs=check_domains, outputs=data)
|
66 |
-
with gr.Tab("STEP 3: Generate SSL"):
|
67 |
-
with gr.Row():
|
68 |
-
with gr.Column():
|
69 |
-
domains_input = gr.Textbox(label="Enter Domains", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
|
70 |
-
wildcard = gr.Checkbox(label="Wildcard SSL", interactive=True, value=False)
|
71 |
-
email_input = gr.Textbox(label="Enter your Email ID", placeholder="[email protected]", type="text", interactive=True)
|
72 |
-
with gr.Row():
|
73 |
-
ca_server = gr.Dropdown(label="Select Certificate Authority", choices=["Let's Encrypt (Testing)","Let's Encrypt", "Buypass (Testing)", "Buypass", "ZeroSSL", "Google (Testing)","Google", "SSL.com"], interactive=True, value="Let's Encrypt (Testing)")
|
74 |
-
key_type = gr.Radio(label="Select SSL key type", choices=["rsa", "ec"], interactive=True, value='ec')
|
75 |
-
key_size_dropdown = gr.Dropdown(label="Select Key Size", choices=['2048', '4096'], value='4096', visible=False) # Initially visible
|
76 |
-
key_curve_dropdown = gr.Dropdown(label="Select Key Curve", choices=['SECP256R1', 'SECP384R1'], value='SECP384R1', visible=True) # Initially hidden
|
77 |
-
key_type.change(fn=update_key_options, inputs=key_type, outputs=[key_size_dropdown, key_curve_dropdown])
|
78 |
-
wildcard.change(fn=update_ca_server, inputs=wildcard, outputs=ca_server)
|
79 |
-
btn3 = gr.Button(value="Generate SSL Certificate")
|
80 |
-
with gr.Row():
|
81 |
-
with gr.Column():
|
82 |
-
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)
|
83 |
-
pvtfile = gr.File(label="Download your Private Key")
|
84 |
-
with gr.Column():
|
85 |
-
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)
|
86 |
-
csrfile = gr.File(label="Download your CSR")
|
87 |
-
with gr.Column():
|
88 |
-
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)
|
89 |
-
crtfile = gr.File(label="Download your SSL Certificate")
|
90 |
-
btn3.click(gen_ssl, inputs=[domains_input, wildcard, email_input, ca_server, key_type, key_size_dropdown, key_curve_dropdown], outputs=[pvt, pvtfile, csr, csrfile, crt, crtfile])
|
91 |
-
try:
|
92 |
-
#webui.queue(default_concurrency_limit=15).launch()
|
93 |
-
webui.queue().launch()
|
94 |
-
except Exception as e:
|
95 |
-
print(f"Error: {e}")
|
96 |
-
|
97 |
-
if __name__ == "__main__":
|
98 |
-
try:
|
99 |
-
app()
|
100 |
-
except Exception as e:
|
101 |
-
print(f"Error: {e}")
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
import gradio as gr
|
4 |
+
from main import main
|
5 |
+
from tools import write_file, get_domains
|
6 |
+
from gen_client_cnames import gen_client_cnames
|
7 |
+
from verify_cname import verify_cname
|
8 |
+
|
9 |
+
def gen_cname(i_domains):
|
10 |
+
cf_domain = "silerudaagartha.eu.org"
|
11 |
+
cname_recs, cname_values = gen_client_cnames(i_domains, cf_domain)
|
12 |
+
table_data = []
|
13 |
+
for rec, value in zip(cname_recs, cname_values):
|
14 |
+
table_data.append([rec, value])
|
15 |
+
return table_data
|
16 |
+
|
17 |
+
def check_cname(domains):
|
18 |
+
data = verify_cname(domains)
|
19 |
+
return data
|
20 |
+
|
21 |
+
def gen_ssl(i_domains, wildcard, email, ca_server, key_type, key_size=None, key_curve=None):
|
22 |
+
if key_type == "rsa":
|
23 |
+
key_curve = None
|
24 |
+
elif key_type == "ec":
|
25 |
+
key_size = None
|
26 |
+
else:
|
27 |
+
key_curve = None
|
28 |
+
if key_size is not None:
|
29 |
+
key_size = int(key_size)
|
30 |
+
pvt, csr, cert = main(i_domains, wildcard, email, ca_server, key_type, key_size, key_curve)
|
31 |
+
path = email.split("@")[0]
|
32 |
+
os.makedirs(path, exist_ok=True)
|
33 |
+
write_file(f"{path}/private.pem", pvt)
|
34 |
+
write_file(f"{path}/domain.csr", csr)
|
35 |
+
write_file(f"{path}/cert.pem", cert)
|
36 |
+
return pvt.decode('utf-8'), f"{path}/private.pem", csr.decode('utf-8'), f"{path}/domain.csr", cert.decode('utf-8'), f"{path}/cert.pem"
|
37 |
+
|
38 |
+
def update_key_options(key_type):
|
39 |
+
if key_type == "rsa":
|
40 |
+
return gr.update(visible=True), gr.update(visible=False)
|
41 |
+
else:
|
42 |
+
return gr.update(visible=False), gr.update(visible=True)
|
43 |
+
|
44 |
+
def update_ca_server(wildcard: bool):
|
45 |
+
if wildcard == False:
|
46 |
+
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)")
|
47 |
+
else:
|
48 |
+
return gr.update(choices=["Let's Encrypt (Testing)","Let's Encrypt", "ZeroSSL", "Google (Testing)","Google", "SSL.com"], value="Let's Encrypt")
|
49 |
+
|
50 |
+
def app():
|
51 |
+
with gr.Blocks(title="Project Gatekeeper - Get free SSL Certificates") as webui:
|
52 |
+
with gr.Tab("STEP 1: Generate CNAME Records"):
|
53 |
+
with gr.Row():
|
54 |
+
cname_domains = gr.Textbox(value="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", label="Enter Domains", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
|
55 |
+
btn1 = gr.Button(value="Generate CNAME Records & Values")
|
56 |
+
with gr.Row():
|
57 |
+
records = gr.Dataframe(label="CNAME Records", headers=["CNAME", "CNAME VALUE"], row_count=(1), col_count=(2))
|
58 |
+
btn1.click(gen_cname, inputs=cname_domains, outputs=records)
|
59 |
+
with gr.Tab("STEP 2: Check CNAME Propagation"):
|
60 |
+
with gr.Row():
|
61 |
+
check_domains = gr.Textbox(label="Enter CNAME", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
|
62 |
+
btn2 = gr.Button(value="Check CNAME Propagation")
|
63 |
+
with gr.Row():
|
64 |
+
data = gr.Dataframe(label="CNAME Records", headers=["CNAME", "Expected CNAME Value", "Found CNAME Value", "CNAME Status"], row_count=(1), col_count=(4))
|
65 |
+
btn2.click(verify_cname, inputs=check_domains, outputs=data)
|
66 |
+
with gr.Tab("STEP 3: Generate SSL"):
|
67 |
+
with gr.Row():
|
68 |
+
with gr.Column():
|
69 |
+
domains_input = gr.Textbox(label="Enter Domains", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
|
70 |
+
wildcard = gr.Checkbox(label="Wildcard SSL", interactive=True, value=False)
|
71 |
+
email_input = gr.Textbox(label="Enter your Email ID", placeholder="[email protected]", type="text", interactive=True)
|
72 |
+
with gr.Row():
|
73 |
+
ca_server = gr.Dropdown(label="Select Certificate Authority", choices=["Let's Encrypt (Testing)","Let's Encrypt", "Buypass (Testing)", "Buypass", "ZeroSSL", "Google (Testing)","Google", "SSL.com"], interactive=True, value="Let's Encrypt (Testing)")
|
74 |
+
key_type = gr.Radio(label="Select SSL key type", choices=["rsa", "ec"], interactive=True, value='ec')
|
75 |
+
key_size_dropdown = gr.Dropdown(label="Select Key Size", choices=['2048', '4096'], value='4096', visible=False) # Initially visible
|
76 |
+
key_curve_dropdown = gr.Dropdown(label="Select Key Curve", choices=['SECP256R1', 'SECP384R1'], value='SECP384R1', visible=True) # Initially hidden
|
77 |
+
key_type.change(fn=update_key_options, inputs=key_type, outputs=[key_size_dropdown, key_curve_dropdown])
|
78 |
+
wildcard.change(fn=update_ca_server, inputs=wildcard, outputs=ca_server)
|
79 |
+
btn3 = gr.Button(value="Generate SSL Certificate")
|
80 |
+
with gr.Row():
|
81 |
+
with gr.Column():
|
82 |
+
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)
|
83 |
+
pvtfile = gr.File(label="Download your Private Key")
|
84 |
+
with gr.Column():
|
85 |
+
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)
|
86 |
+
csrfile = gr.File(label="Download your CSR")
|
87 |
+
with gr.Column():
|
88 |
+
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)
|
89 |
+
crtfile = gr.File(label="Download your SSL Certificate")
|
90 |
+
btn3.click(gen_ssl, inputs=[domains_input, wildcard, email_input, ca_server, key_type, key_size_dropdown, key_curve_dropdown], outputs=[pvt, pvtfile, csr, csrfile, crt, crtfile])
|
91 |
+
try:
|
92 |
+
#webui.queue(default_concurrency_limit=15).launch()
|
93 |
+
webui.queue().launch()
|
94 |
+
except Exception as e:
|
95 |
+
print(f"Error: {e}")
|
96 |
+
|
97 |
+
if __name__ == "__main__":
|
98 |
+
try:
|
99 |
+
app()
|
100 |
+
except Exception as e:
|
101 |
+
print(f"Error: {e}")
|