Add fetch button to retrieve certifiate from domain provided #289

This commit is contained in:
Marcus Hill
2022-01-18 20:04:00 +00:00
parent 5e61d8733a
commit 4eed8be0aa
4 changed files with 82 additions and 13 deletions

View File

@@ -135,4 +135,32 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
</div>
</div>
<?php include("add_certificate_modal.php"); ?>
<?php include("add_certificate_modal.php"); ?>
<script type="text/javascript">
function fetchSSL()
{
// Get the domain name input
var domain = document.getElementById("domain").value;
//Send a GET request to post.php as post.php?fetch_certificate=TRUE&domain=DOMAIN
jQuery.get(
"post.php",
{fetch_certificate: 'TRUE', domain: domain},
function(data){
//If we get a response from post.php, parse it as JSON
const ssl_data = JSON.parse(data);
if(ssl_data.success == "TRUE"){
// Fill the form fields with the cert data
document.getElementById("issued_by").value = ssl_data.issued_by;
document.getElementById("expire").value = ssl_data.expire;
document.getElementById("public_key").value = ssl_data.public_key;
}
else{
alert("Error whilst parsing/retrieving details for domain")
}
}
);
}
</script>