Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add button to easily copy signature command #142

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ <h2>Step 3: Sign API Requests<span id="step3_pending"> (waiting...)</span></h2>
<span id="step3_commands">
</span>
<span id="signing_template" style="display:none;">
<input type="text" value="echo ..." readonly/><br/>
<input type="text" value="echo ..." readonly/><input type="button" value="Copy Text" onclick="#"/><br/>
<input id="challenge_sig_foobar_com" type="text" placeholder='Paste the hex output here (e.g. "(stdin)= f2cf67e4...")'/><br/>
</span>
</div>
Expand Down
34 changes: 26 additions & 8 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -402,25 +405,31 @@ 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"));
}

// 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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -846,3 +858,9 @@ function checkAllDomains(){
}));
}

function copyChallenge(elem) {
var copyText = document.getElementById(elem.target.fnParam);
copyText.select();
document.execCommand("Copy");
}