diff --git a/index.html b/index.html index c3b08bb..c7e9942 100644 --- a/index.html +++ b/index.html @@ -224,7 +224,7 @@

Step 3: Sign API Requests (waiting...)

diff --git a/js/index.js b/js/index.js index b983829..13c012f 100644 --- a/js/index.js +++ b/js/index.js @@ -386,12 +386,15 @@ function validateCSR(e){ // build the account registration signature command var account_template = document.getElementById("signing_template").cloneNode(true); + account_template.querySelectorAll("input")[0].id = "account_sig_cmd"; account_template.querySelectorAll("input")[0].value = "" + "PRIV_KEY=./account.key; " + "echo -n \"" + ACCOUNT_PUBKEY['protected'] + "." + ACCOUNT_PUBKEY['payload'] + "\" | " + "openssl dgst -sha256 -hex -sign $PRIV_KEY"; - account_template.querySelectorAll("input")[1].id = "account_sig"; - account_template.querySelectorAll("input")[1].value = ""; + account_template.querySelectorAll("input")[1].addEventListener('click',copyChallenge,false); + account_template.querySelectorAll("input")[1].fnParam = "account_sig_cmd"; + account_template.querySelectorAll("input")[2].id = "account_sig"; + account_template.querySelectorAll("input")[2].value = ""; account_template.style.display = null; document.getElementById("step3_commands").appendChild(account_template); document.getElementById("step3_commands").appendChild(document.createElement("br")); @@ -402,12 +405,15 @@ function validateCSR(e){ domainString += d + ", "; var d_ = d.replace(/\./g, "_"); var domain_template = document.getElementById("signing_template").cloneNode(true); + domain_template.querySelectorAll("input")[0].id = "domain_sig_" + d_+"cmd"; domain_template.querySelectorAll("input")[0].value = "" + "PRIV_KEY=./account.key; " + "echo -n \"" + DOMAINS[d]['request_protected'] + "." + DOMAINS[d]['request_payload'] + "\" | " + "openssl dgst -sha256 -hex -sign $PRIV_KEY"; - domain_template.querySelectorAll("input")[1].id = "domain_sig_" + d_; - domain_template.querySelectorAll("input")[1].value = ""; + domain_template.querySelectorAll("input")[1].addEventListener('click',copyChallenge,false); + domain_template.querySelectorAll("input")[1].fnParam = "domain_sig_" + d_+"cmd"; + domain_template.querySelectorAll("input")[2].id = "domain_sig_" + d_; + domain_template.querySelectorAll("input")[2].value = ""; domain_template.style.display = null; document.getElementById("step3_commands").appendChild(domain_template); document.getElementById("step3_commands").appendChild(document.createElement("br")); @@ -415,12 +421,15 @@ function validateCSR(e){ // build the csr registration signature command var csr_template = document.getElementById("signing_template").cloneNode(true); + csr_template.querySelectorAll("input")[0].id = "csr_sig_cmd"; csr_template.querySelectorAll("input")[0].value = "" + "PRIV_KEY=./account.key; " + "echo -n \"" + CSR['protected'] + "." + CSR['payload'] + "\" | " + "openssl dgst -sha256 -hex -sign $PRIV_KEY"; - csr_template.querySelectorAll("input")[1].id = "csr_sig"; - csr_template.querySelectorAll("input")[1].value = ""; + csr_template.querySelectorAll("input")[1].addEventListener('click',copyChallenge,false); + csr_template.querySelectorAll("input")[1].fnParam = "csr_sig_cmd"; + csr_template.querySelectorAll("input")[2].id = "csr_sig"; + csr_template.querySelectorAll("input")[2].value = ""; csr_template.style.display = null; document.getElementById("step3_commands").appendChild(csr_template); @@ -538,12 +547,15 @@ function validateInitialSigs(e){ // build step 4 commands for this domain var challenge_cmd = document.getElementById("signing_template").cloneNode(true); + challenge_cmd.querySelectorAll("input")[0].id = "challenge_sig_" + d_+"cmd"; challenge_cmd.querySelectorAll("input")[0].value = "" + "PRIV_KEY=./account.key; " + "echo -n \"" + DOMAINS[d]['challenge_protected'] + "." + DOMAINS[d]['challenge_payload'] + "\" | " + "openssl dgst -sha256 -hex -sign $PRIV_KEY"; - challenge_cmd.querySelectorAll("input")[1].id = "challenge_sig_" + d_; - challenge_cmd.querySelectorAll("input")[1].value = ""; + challenge_cmd.querySelectorAll("input")[1].addEventListener('click',copyChallenge,false); + challenge_cmd.querySelectorAll("input")[1].fnParam = "challenge_sig_" + d_+"cmd"; + challenge_cmd.querySelectorAll("input")[2].id = "challenge_sig_" + d_; + challenge_cmd.querySelectorAll("input")[2].value = ""; challenge_cmd.style.display = null; template.querySelector(".step4_commands").appendChild(challenge_cmd); @@ -846,3 +858,9 @@ function checkAllDomains(){ })); } +function copyChallenge(elem) { + var copyText = document.getElementById(elem.target.fnParam); + copyText.select(); + document.execCommand("Copy"); +} +