This commit is contained in:
1 parent
39c27b0de3
commit
e6526fb780
8 files changed
+169
-114
No files matched your search
@@ -0,0 +1,65 @@
|
||||
const createRootCertificateModal = bootstrap.Modal.getOrCreateInstance(
|
||||
document.querySelector("#createRootCertificate"),
|
||||
);
|
||||
const createRootCrtButton = document.querySelector("#createRootCrt");
|
||||
|
||||
const rootcommonnameinput = document.querySelector("#rootcommonname");
|
||||
const rootorganizationinput = document.querySelector("#rootorganizationname");
|
||||
const rootorganizationalunitinput = document.querySelector(
|
||||
"#rootorganizationalunit",
|
||||
);
|
||||
const rootcountryinput = document.querySelector("#rootCountry");
|
||||
const rootlocalityinput = document.querySelector("#rootLocality");
|
||||
const rootprovinceinput = document.querySelector("#rootProvince");
|
||||
const rootstreetaddressinput = document.querySelector("#rootStreetAddress");
|
||||
const rootpostalcodeinput = document.querySelector("#rootPostalCode");
|
||||
const rootvalidityyearsinput = document.querySelector("#rootValidityYears");
|
||||
const rootkeypasswordinput = document.querySelector("#rootkeypassword");
|
||||
|
||||
const getRootCrt = () => {
|
||||
fetch(window.location.origin + "/api/certs/root")
|
||||
.then((data) => data.json())
|
||||
.then((jsondata) => {
|
||||
console.log(jsondata);
|
||||
})
|
||||
.catch((error) => {
|
||||
createRootCertificateModal.show();
|
||||
});
|
||||
};
|
||||
|
||||
getRootCrt();
|
||||
|
||||
createRootCrtButton.addEventListener("click", () => {
|
||||
const newRootCertificate = {
|
||||
CommonName: rootcommonnameinput.value,
|
||||
Organization: [rootorganizationinput.value],
|
||||
OrganizationalUnit: [rootorganizationalunitinput.value],
|
||||
Country: [rootcountryinput.value],
|
||||
Locality: [rootlocalityinput.value],
|
||||
Province: [rootprovinceinput.value],
|
||||
StreetAddress: [rootstreetaddressinput.value],
|
||||
PostalCode: [rootpostalcodeinput.value],
|
||||
ValidityYears: parseInt(rootvalidityyearsinput.value),
|
||||
KeyPassword: rootkeypasswordinput.value,
|
||||
};
|
||||
fetch(window.location.origin + "/api/certs/root", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(newRootCertificate),
|
||||
}).then((data) =>
|
||||
data
|
||||
.json()
|
||||
.then((jsondata) => {
|
||||
console.log(jsondata);
|
||||
if (jsondata.status === "ok") {
|
||||
alert("Root certificate created successfully");
|
||||
createRootCertificateModal.hide();
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
alert(error);
|
||||
}),
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user