File size: 2,610 Bytes
219f61d
 
 
 
 
 
 
 
 
 
 
 
 
e693367
219f61d
e693367
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219f61d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sys
import requests
import gradio as gr
import json

def requestAPI(domain):
    url = f'https://ssl-checker.io/api/v1/check/{domain}'
    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise an error for bad responses
    except requests.exceptions.RequestException as e:
        return {'error': f'Request failed: {e}'}
    
    # Process the data to match the desired output format
    data = response.json()
    result = data.get('result', {})

    formatted_data = {
        "Host": result.get("host", ""),
        "Status": data.get("status", ""),
        "Response Time": f"{data.get('response_time_sec', '0')}s",
        "Resolved IP": result.get("resolved_ip", ""),
        "Issued to": result.get("issued_to", ""),
        "Issued Organization": result.get("issued_o", None),
        "Issuer Country": result.get("issuer_c", ""),
        "Issuer CN": result.get("issuer_cn", ""),
        "Issuer Organization": result.get("issuer_o", ""),
        "Cert S/N": result.get("cert_sn", ""),
        "Cert SHA1": result.get("cert_sha1", ""),
        "Cert Algorithm": result.get("cert_alg", ""),
        "Cert Version": result.get("cert_ver", ""),
        "Cert SANs": result.get("cert_sans", ""),
        "Cert Expired": result.get("cert_exp", False),
        "Cert Valid": result.get("cert_valid", False),
        "Valid From": result.get("valid_from", ""),
        "Valid Until": result.get("valid_till", ""),
        "Validity Days": result.get("validity_days", 0),
        "Days Left": result.get("days_left", 0),
        "Valid Days to Expire": result.get("valid_days_to_expire", 0),
        "HSTS Header Enabled": result.get("hsts_header_enabled", False)
    }
    
    return json.dumps(formatted_data, indent=2)  # Format as pretty JSON

def app():
    with gr.Blocks(title="Project Gatekeeper - Get free SSL Certificates") as webui:
        domains_input = gr.Textbox(
            label="Enter Domains",
            placeholder="thenayankasturi.eu.org, dash.thenayankasturi.eu.org, www.thenayankasturi.eu.org",
            type="text",
            interactive=True
        )
        data = gr.TextArea(
            label="Data",
            placeholder="Data will be displayed here in JSON format",
            type="text",
            interactive=False
        )
        btn = gr.Button(value="Generate SSL Certificate")
        btn.click(requestAPI, inputs=domains_input, outputs=data)
    
    try:
        webui.queue(default_concurrency_limit=15).launch()
    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    app()