diff --git a/src/index.html b/src/index.html
index 01acf34..a18c899 100644
--- a/src/index.html
+++ b/src/index.html
@@ -23,6 +23,11 @@
Please input your name as it should be added to
your certificate
+
+ Password for your client certificate
+
+
RSA Key Size
@@ -53,10 +58,16 @@
+
+
+
+ Send signing request
+
+
+
- Send signing request
@@ -82,6 +93,7 @@
const keyElement = document.getElementById('key');
document.getElementById('csr-form').onsubmit = function (event) {
const subject = event.target["nameInput"].value;
+ const password = event.target["passwordInput"].value;
const keySize = parseInt(event.target["keySize"].value);
if (isNaN(keySize)) {
return false;
@@ -127,8 +139,22 @@
.then(data => {
console.log(data);
document.getElementById("crt").innerHTML = data["certificate"];
+ const certificate = forge.pki.certificateFromPem(data["certificate"]);
+ // browsers have trouble importing anything but 3des encrypted PKCS#12
+ const p12asn1 = forge.pkcs12.toPkcs12Asn1(
+ keys.privateKey, certificate, password,
+ {algorithm: '3des'}
+ );
+ const p12Der = forge.asn1.toDer(p12asn1).getBytes();
+ const p12B64 = forge.util.encode64(p12Der);
+
+ const a = document.createElement('a');
+ a.download = 'client_certificate.p12';
+ a.setAttribute('href', 'data:application/x-pkcs12;base64,' + p12B64);
+ a.appendChild(document.createTextNode("Download"));
+ document.getElementById('result').appendChild(a);
});
- })
+ });
sendButton.removeAttribute("disabled");
sendButton.classList.remove("disabled");
}