raannakasturi commited on
Commit
c618bab
·
verified ·
1 Parent(s): 1d6fc28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +78 -71
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
- pvt, csr, cert, email_status = main(i_domains, wildcard, email, ca_server, key_type, key_size, key_curve)
16
- print("SSL Certificate generated successfully")
17
- try:
18
- return pvt.decode('utf-8'), csr.decode('utf-8'), cert.decode('utf-8'), email_status
19
- except:
20
- return pvt, csr, cert, email_status
21
-
22
- def update_key_options(key_type):
23
- if key_type == "rsa":
24
- return gr.update(visible=True), gr.update(visible=False)
25
- else:
26
- return gr.update(visible=False), gr.update(visible=True)
27
-
28
- def update_ca_server(wildcard: bool):
29
- if wildcard == False:
30
- 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)")
31
- else:
32
- return gr.update(choices=["Let's Encrypt (Testing)","Let's Encrypt", "ZeroSSL", "Google (Testing)","Google", "SSL.com"], value="Let's Encrypt")
33
-
34
- def update_buypass_options(ca_server):
35
- if ca_server == "Buypass (Testing)" or ca_server == "Buypass":
36
- return gr.update(choices=['SECP256R1'])
37
- else:
38
- return gr.update(choices=['SECP256R1', 'SECP384R1'])
39
-
40
- def app():
41
- with gr.Blocks(title="Project Gatekeeper - Get free SSL Certificates") as webui:
42
- with gr.Row():
43
- with gr.Column():
44
- domains_input = gr.Textbox(label="Enter Domains", placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org", type="text", interactive=True)
45
- wildcard = gr.Checkbox(label="Wildcard SSL", interactive=True, value=False)
46
- email_input = gr.Textbox(label="Enter your Email ID", placeholder="[email protected]", type="text", interactive=True)
47
- with gr.Row():
48
- 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)")
49
- key_type = gr.Radio(label="Select SSL key type", choices=["rsa", "ecc"], interactive=True, value='ecc')
50
- key_size_dropdown = gr.Dropdown(label="Select Key Size", choices=['2048', '4096'], value='4096', visible=False) # Initially visible
51
- key_curve_dropdown = gr.Dropdown(label="Select Key Curve", choices=['SECP256R1', 'SECP384R1'], value='SECP256R1', visible=True) # Initially hidden
52
- ca_server.change(fn=update_buypass_options, inputs=ca_server, outputs=key_curve_dropdown)
53
- key_type.change(fn=update_key_options, inputs=key_type, outputs=[key_size_dropdown, key_curve_dropdown])
54
- wildcard.change(fn=update_ca_server, inputs=wildcard, outputs=ca_server)
55
- btn = gr.Button(value="Generate SSL Certificate")
56
- with gr.Row():
57
- with gr.Column():
58
- 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)
59
- with gr.Column():
60
- 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)
61
- with gr.Column():
62
- 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)
63
- email_status = gr.Textbox(label="Email Status", placeholder="Email status will appear here, after sending email", type="text", interactive=False)
64
- 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])
65
- try:
66
- webui.queue(default_concurrency_limit=15).launch()
67
- except Exception as e:
68
- print(f"Error: {e}")
69
-
70
- if __name__ == "__main__":
71
- app()
 
 
 
 
 
 
 
 
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="[email protected]", 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()