Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,48 +1,48 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from cryptography import x509
|
3 |
-
from cryptography.hazmat.backends import default_backend
|
4 |
-
from decode import decode_ssl_certificate
|
5 |
-
|
6 |
-
def decode(cert):
|
7 |
-
cert = cert.encode()
|
8 |
-
try:
|
9 |
-
decoded_cert = x509.load_pem_x509_certificate(cert, default_backend())
|
10 |
-
if decoded_cert:
|
11 |
-
status = "Success"
|
12 |
-
message = "Certificate decoded successfully."
|
13 |
-
decoded_data = decode_ssl_certificate(decoded_cert)
|
14 |
-
return {
|
15 |
-
"status": status,
|
16 |
-
"message": message,
|
17 |
-
"data": decoded_data
|
18 |
-
}
|
19 |
-
else:
|
20 |
-
return {
|
21 |
-
"status": status,
|
22 |
-
"message": message,
|
23 |
-
"data": None
|
24 |
-
}
|
25 |
-
except Exception as e:
|
26 |
-
status = "Failed"
|
27 |
-
message = "Failed to decode certificate. Please make sure you have uploaded a valid certificate file."
|
28 |
-
return {
|
29 |
-
"status": status,
|
30 |
-
"message": message,
|
31 |
-
"data": e
|
32 |
-
}
|
33 |
-
|
34 |
-
def app():
|
35 |
-
with gr.Blocks(title="Project Gatekeeper - Get free SSL Certificates") as webui:
|
36 |
-
with gr.Row():
|
37 |
-
ssl = gr.Textbox(label="Enter Domains", type="text", interactive=True)
|
38 |
-
with gr.Row():
|
39 |
-
decoded_data = gr.Textbox(label="Enter Domains", type="text", interactive=False, show_copy_button=True)
|
40 |
-
btn = gr.Button(value="Generate SSL Certificate")
|
41 |
-
btn.click(decode, inputs=ssl, outputs=decoded_data)
|
42 |
-
try:
|
43 |
-
webui.queue(default_concurrency_limit=15).launch()
|
44 |
-
except Exception as e:
|
45 |
-
print(f"Error: {e}")
|
46 |
-
|
47 |
-
if __name__ == "__main__":
|
48 |
app()
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from cryptography import x509
|
3 |
+
from cryptography.hazmat.backends import default_backend
|
4 |
+
from decode import decode_ssl_certificate
|
5 |
+
|
6 |
+
def decode(cert) -> dict:
|
7 |
+
cert = cert.encode()
|
8 |
+
try:
|
9 |
+
decoded_cert = x509.load_pem_x509_certificate(cert, default_backend())
|
10 |
+
if decoded_cert:
|
11 |
+
status = "Success"
|
12 |
+
message = "Certificate decoded successfully."
|
13 |
+
decoded_data = decode_ssl_certificate(decoded_cert)
|
14 |
+
return {
|
15 |
+
"status": status,
|
16 |
+
"message": message,
|
17 |
+
"data": decoded_data
|
18 |
+
}
|
19 |
+
else:
|
20 |
+
return {
|
21 |
+
"status": status,
|
22 |
+
"message": message,
|
23 |
+
"data": None
|
24 |
+
}
|
25 |
+
except Exception as e:
|
26 |
+
status = "Failed"
|
27 |
+
message = "Failed to decode certificate. Please make sure you have uploaded a valid certificate file."
|
28 |
+
return {
|
29 |
+
"status": status,
|
30 |
+
"message": message,
|
31 |
+
"data": e
|
32 |
+
}
|
33 |
+
|
34 |
+
def app():
|
35 |
+
with gr.Blocks(title="Project Gatekeeper - Get free SSL Certificates") as webui:
|
36 |
+
with gr.Row():
|
37 |
+
ssl = gr.Textbox(label="Enter Domains", type="text", interactive=True)
|
38 |
+
with gr.Row():
|
39 |
+
decoded_data = gr.Textbox(label="Enter Domains", type="text", interactive=False, show_copy_button=True)
|
40 |
+
btn = gr.Button(value="Generate SSL Certificate")
|
41 |
+
btn.click(decode, inputs=ssl, outputs=decoded_data)
|
42 |
+
try:
|
43 |
+
webui.queue(default_concurrency_limit=15).launch()
|
44 |
+
except Exception as e:
|
45 |
+
print(f"Error: {e}")
|
46 |
+
|
47 |
+
if __name__ == "__main__":
|
48 |
app()
|