Spaces:
Sleeping
Sleeping
File size: 6,293 Bytes
1f9e9c1 a655661 d7d7109 a655661 1f9e9c1 d7d7109 347c128 d7d7109 a655661 d7d7109 a655661 d7d7109 77c46b1 1f9e9c1 d7d7109 1f9e9c1 d7d7109 1f9e9c1 a655661 d7d7109 a655661 d7d7109 a655661 d7d7109 a655661 d7d7109 a655661 1f9e9c1 347c128 1f9e9c1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
import os
import sys
import gradio as gr
from main import main
from tools import write_file, get_domains
from gen_client_cnames import gen_client_cnames
from verify_cname import verify_cname
def gen_cname(i_domains):
cf_domain = "silerudaagartha.eu.org"
cname_recs, cname_values = gen_client_cnames(i_domains, cf_domain)
table_data = []
for rec, value in zip(cname_recs, cname_values):
table_data.append([rec, value])
return table_data
def check_cname(domains):
data = verify_cname(domains)
return data
def gen_ssl(i_domains, wildcard, email, ca_server, key_type, key_size=None, key_curve=None):
if key_type == "rsa":
key_curve = None
elif key_type == "ec":
key_size = None
else:
key_curve = None
if key_size is not None:
key_size = int(key_size)
pvt, csr, cert = main(i_domains, wildcard, email, ca_server, key_type, key_size, key_curve)
path = email.split("@")[0]
os.makedirs(path, exist_ok=True)
write_file(f"{path}/private.pem", pvt)
write_file(f"{path}/domain.csr", csr)
write_file(f"{path}/cert.pem", cert)
return pvt, f"{path}/private.pem", csr, f"{path}/domain.csr", cert, f"{path}/cert.pem"
def update_key_options(key_type):
if key_type == "rsa":
return gr.update(visible=True), gr.update(visible=False)
else:
return gr.update(visible=False), gr.update(visible=True)
def update_ca_server(wildcard: bool):
if wildcard == False:
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)")
else:
return gr.update(choices=["Let's Encrypt (Testing)","Let's Encrypt", "ZeroSSL", "Google (Testing)","Google", "SSL.com"], value="Let's Encrypt")
def app():
with gr.Blocks(title="Project Gatekeeper - Get free SSL Certificates") as webui:
with gr.Tab("STEP 1: Generate CNAME Records"):
with gr.Row():
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)
btn1 = gr.Button(value="Generate CNAME Records & Values")
with gr.Row():
records = gr.Dataframe(label="CNAME Records", headers=["CNAME", "CNAME VALUE"], row_count=(1), col_count=(2))
btn1.click(gen_cname, inputs=cname_domains, outputs=records)
with gr.Tab("STEP 2: Check CNAME Propagation"):
with gr.Row():
check_domains = gr.Textbox(label="Enter CNAME", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
btn2 = gr.Button(value="Check CNAME Propagation")
with gr.Row():
data = gr.Dataframe(label="CNAME Records", headers=["CNAME", "Expected CNAME Value", "Found CNAME Value", "CNAME Status"], row_count=(1), col_count=(4))
btn2.click(verify_cname, inputs=check_domains, outputs=data)
with gr.Tab("STEP 3: Generate SSL"):
with gr.Row():
with gr.Column():
domains_input = gr.Textbox(label="Enter Domains", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
wildcard = gr.Checkbox(label="Wildcard SSL", interactive=True, value=False)
email_input = gr.Textbox(label="Enter your Email ID", placeholder="[email protected]", type="text", interactive=True)
with gr.Row():
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)")
key_type = gr.Radio(label="Select SSL key type", choices=["rsa", "ec"], interactive=True, value='ec')
key_size_dropdown = gr.Dropdown(label="Select Key Size", choices=['2048', '4096'], value='4096', visible=False) # Initially visible
key_curve_dropdown = gr.Dropdown(label="Select Key Curve", choices=['SECP256R1', 'SECP384R1'], value='SECP384R1', visible=True) # Initially hidden
key_type.change(fn=update_key_options, inputs=key_type, outputs=[key_size_dropdown, key_curve_dropdown])
wildcard.change(fn=update_ca_server, inputs=wildcard, outputs=ca_server)
btn3 = gr.Button(value="Generate SSL Certificate")
with gr.Row():
with gr.Column():
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)
pvtfile = gr.File(label="Download your Private Key")
with gr.Column():
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)
csrfile = gr.File(label="Download your CSR")
with gr.Column():
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)
crtfile = gr.File(label="Download your SSL Certificate")
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])
try:
#webui.queue(default_concurrency_limit=15).launch()
webui.queue().launch()
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
try:
app()
except Exception as e:
print(f"Error: {e}")
|