// Add event listener to button document.getElementById("ssl").addEventListener("click", function () { getSSL(); }); // Add enter key listener to input document.getElementById("domain").addEventListener("keyup", function (event) { if (event.key === "Enter") { getSSL(); } }); function getSSL() { // Get the input value const domain = document.getElementById("domain").value; // Send a GET request to the API fetch(`/api/v1/ssl/${domain}`) .then(response => response.json()) .then(data => { // Check if the request was successful if (data.success) { // Display the results // document.getElementById("results").innerHTML = `

SSL Certificate Details

//

IP Address: ${data.ip}

//

Webserver TLSA: ${data.tlsa.server}

//

Nameserver TLSA: ${data.tlsa.nameserver} ${data.tlsa.match ? "(Match)" : "(No Match)"}

//

Certificate Names: ${data.cert.domains.join(", ")}

//

Expiry Date: ${data.cert.expiry_date} UTC

//

Valid: ${data.cert.valid ? "Yes" : "No"}

`; document.getElementById("results").innerHTML = `

SSL Certificate Details

`; } else { // Display an error message document.getElementById("results").innerHTML = `

Error

${data.message}

`; } }) .catch(error => { // Display an error message document.getElementById("results").innerHTML = `

Error

${error.message}

`; }); } // On load check if params are present if (window.location.search) { const params = new URLSearchParams(window.location.search); const domain = params.get('domain'); if (domain) { // Add domain to input document.getElementById("domain").value = domain; getSSL(domain); } }