Spaces:
Sleeping
Sleeping
Commit
·
d045095
1
Parent(s):
41674cb
chore: Update app.py and requirements.txt files
Browse files- .gitignore +1 -0
- app.py +32 -5
- main.py +5 -13
- requirements.txt +1 -0
.gitignore
CHANGED
@@ -4,3 +4,4 @@ certificate*
|
|
4 |
/thenayankasturi*
|
5 |
/__pycache__
|
6 |
*.json
|
|
|
|
4 |
/thenayankasturi*
|
5 |
/__pycache__
|
6 |
*.json
|
7 |
+
/venv
|
app.py
CHANGED
@@ -1,9 +1,19 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from main import main
|
|
|
3 |
|
4 |
def run(i_domains, wildcard, email, ca_server, key_type, key_size=None, key_curve=None):
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
def update_key_options(key_type):
|
9 |
if key_type == "rsa":
|
@@ -11,6 +21,12 @@ def update_key_options(key_type):
|
|
11 |
else:
|
12 |
return gr.update(visible=False), gr.update(visible=True)
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
def app():
|
15 |
with gr.Blocks() as webui:
|
16 |
with gr.Row():
|
@@ -31,12 +47,23 @@ def app():
|
|
31 |
with gr.Column():
|
32 |
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)
|
33 |
pvtfile = gr.File(label="Download your Private Key")
|
|
|
|
|
|
|
34 |
with gr.Column():
|
35 |
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)
|
36 |
crtfile = gr.File(label="Download your SSL Certificate")
|
37 |
|
38 |
-
btn.click(run, inputs=[domains_input, wildcard, email_input, ca_server, key_type, key_size_dropdown, key_curve_dropdown], outputs=[pvt, pvtfile, crt, crtfile])
|
39 |
-
|
|
|
|
|
|
|
|
|
40 |
|
41 |
if __name__ == "__main__":
|
42 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
import gradio as gr
|
4 |
from main import main
|
5 |
+
from tools import write_file
|
6 |
|
7 |
def run(i_domains, wildcard, email, ca_server, key_type, key_size=None, key_curve=None):
|
8 |
+
if key_size is not None:
|
9 |
+
key_size = int(key_size)
|
10 |
+
pvt, csr, cert = main(i_domains, wildcard, email, ca_server, key_type, key_size, key_curve)
|
11 |
+
path = email.split("@")[0]
|
12 |
+
os.makedirs(path, exist_ok=True)
|
13 |
+
write_file(f"{path}/private.pem", pvt)
|
14 |
+
write_file(f"{path}/domain.csr", csr)
|
15 |
+
write_file(f"{path}/cert.pem", cert)
|
16 |
+
return pvt, f"{path}/private.pem", csr, f"{path}/domain.csr", cert, f"{path}/cert.pem"
|
17 |
|
18 |
def update_key_options(key_type):
|
19 |
if key_type == "rsa":
|
|
|
21 |
else:
|
22 |
return gr.update(visible=False), gr.update(visible=True)
|
23 |
|
24 |
+
def update_ca_server(wildcard: bool):
|
25 |
+
if wildcard:
|
26 |
+
return gr.update(choices=["Let's Encrypt (Testing)","Let's Encrypt", "ZeroSSL", "Google (Testing)","Google", "SSL.com"], value="Let's Encrypt (Testing)")
|
27 |
+
else:
|
28 |
+
return gr.update(choices=["Let's Encrypt (Testing)","Let's Encrypt", "Buypass (Testing)", "Buypass", "ZeroSSL", "Google (Testing)","Google", "SSL.com"], value="Let's Encrypt")
|
29 |
+
|
30 |
def app():
|
31 |
with gr.Blocks() as webui:
|
32 |
with gr.Row():
|
|
|
47 |
with gr.Column():
|
48 |
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)
|
49 |
pvtfile = gr.File(label="Download your Private Key")
|
50 |
+
with gr.Column():
|
51 |
+
csr = 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)
|
52 |
+
csrfile = gr.File(label="Download your SSL Certificate")
|
53 |
with gr.Column():
|
54 |
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)
|
55 |
crtfile = gr.File(label="Download your SSL Certificate")
|
56 |
|
57 |
+
btn.click(run, inputs=[domains_input, wildcard, email_input, ca_server, key_type, key_size_dropdown, key_curve_dropdown], outputs=[pvt, pvtfile, csr, csrfile, crt, crtfile])
|
58 |
+
try:
|
59 |
+
webui.queue(default_concurrency_limit=15).launch(share=True, server_port=7860)
|
60 |
+
except Exception as e:
|
61 |
+
print(f"Error: {e}")
|
62 |
+
sys.exit(1)
|
63 |
|
64 |
if __name__ == "__main__":
|
65 |
+
try:
|
66 |
+
app()
|
67 |
+
except Exception as e:
|
68 |
+
print(f"Error: {e}")
|
69 |
+
sys.exit(1)
|
main.py
CHANGED
@@ -2,7 +2,7 @@ import os
|
|
2 |
import sys
|
3 |
import time
|
4 |
from genPVTCSR import gen_pvt_csr
|
5 |
-
from tools import get_domains, get_ca_server, get_kid_hmac, extract_subdomains
|
6 |
from acme_tools import pg_client, new_account
|
7 |
from getTokenCert import get_tokens, verify_tokens
|
8 |
from gen_records import txt_recs
|
@@ -46,9 +46,6 @@ def main(i_domains, wildcard, email, ca_server, key_type, key_size=None, key_cur
|
|
46 |
else:
|
47 |
kid = nkid
|
48 |
hmac = nhmac
|
49 |
-
print("KID:",kid)
|
50 |
-
print("HMAC:",hmac)
|
51 |
-
print(f"CA SERVER({ca_server}):", ca_server_url)
|
52 |
account = new_account(pgk_client, email, kid=kid, hmac=hmac)
|
53 |
if not account:
|
54 |
exit()
|
@@ -73,16 +70,11 @@ def main(i_domains, wildcard, email, ca_server, key_type, key_size=None, key_cur
|
|
73 |
print("TXT records deleted successfully")
|
74 |
except Exception as e:
|
75 |
print(f"Error deleting TXT records or no TXT records exists: {e}")
|
76 |
-
|
77 |
-
|
78 |
-
write_file(f"{path}/private.pem", private_key)
|
79 |
-
write_file(f"{path}/domain.csr", csr)
|
80 |
-
write_file(f"{path}/cert.pem", cert)
|
81 |
-
return private_key, f"{path}/private.pem", cert, f"{path}/cert.pem"
|
82 |
-
"""
|
83 |
if __name__ == "__main__":
|
84 |
DOMAINS = 'thenayankasturi.eu.org, *.thenayankasturi.eu.org'
|
85 |
-
ca_server = "
|
86 |
EMAIL = "[email protected]"
|
87 |
key_type = "ec"
|
88 |
key_curve = "ec256"
|
@@ -90,4 +82,4 @@ if __name__ == "__main__":
|
|
90 |
KID = None
|
91 |
HMAC = None
|
92 |
main(i_domains=DOMAINS, wildcard=True, email=EMAIL, ca_server=ca_server, key_type=key_type, key_size=key_size,key_curve=key_curve, kid=KID, hmac=HMAC)
|
93 |
-
|
|
|
2 |
import sys
|
3 |
import time
|
4 |
from genPVTCSR import gen_pvt_csr
|
5 |
+
from tools import get_domains, get_ca_server, get_kid_hmac, extract_subdomains
|
6 |
from acme_tools import pg_client, new_account
|
7 |
from getTokenCert import get_tokens, verify_tokens
|
8 |
from gen_records import txt_recs
|
|
|
46 |
else:
|
47 |
kid = nkid
|
48 |
hmac = nhmac
|
|
|
|
|
|
|
49 |
account = new_account(pgk_client, email, kid=kid, hmac=hmac)
|
50 |
if not account:
|
51 |
exit()
|
|
|
70 |
print("TXT records deleted successfully")
|
71 |
except Exception as e:
|
72 |
print(f"Error deleting TXT records or no TXT records exists: {e}")
|
73 |
+
return private_key, csr, cert
|
74 |
+
'''
|
|
|
|
|
|
|
|
|
|
|
75 |
if __name__ == "__main__":
|
76 |
DOMAINS = 'thenayankasturi.eu.org, *.thenayankasturi.eu.org'
|
77 |
+
ca_server = "Let's Encrypt" #Let's Encrypt (Testing), Let's Encrypt, Buypass (Testing), Buypass, ZeroSSL, Google (Testing), Google, SSL.com
|
78 |
EMAIL = "[email protected]"
|
79 |
key_type = "ec"
|
80 |
key_curve = "ec256"
|
|
|
82 |
KID = None
|
83 |
HMAC = None
|
84 |
main(i_domains=DOMAINS, wildcard=True, email=EMAIL, ca_server=ca_server, key_type=key_type, key_size=key_size,key_curve=key_curve, kid=KID, hmac=HMAC)
|
85 |
+
'''
|
requirements.txt
CHANGED
@@ -2,3 +2,4 @@ josepy==1.14.0
|
|
2 |
python-dotenv
|
3 |
acme==2.11.0
|
4 |
google-cloud-public-ca==0.3.9
|
|
|
|
2 |
python-dotenv
|
3 |
acme==2.11.0
|
4 |
google-cloud-public-ca==0.3.9
|
5 |
+
gradio
|