Browse Source

multiple domains

master
AJ ONeal 5 years ago
parent
commit
5a229ef27f
  1. 79
      app/index.html
  2. 48
      app/js/greenlock.js

79
app/index.html

@ -151,7 +151,7 @@
<br> <br>
<br> <br>
--> -->
<button class="button-next" type="submit">Next</button> <button class="button-next js-account-next" type="submit">Next</button>
<div class="email-usage"> <div class="email-usage">
Why do we need your email? Why do we need your email?
We link your SSL certificates to the email you use so that you'll We link your SSL certificates to the email you use so that you'll
@ -177,52 +177,59 @@
<div></div> <div></div>
</label> </label>
</div> </div>
<div>
<div class="js-acme-verification-http-01"> <div class="js-acme-verification-http-01">
<h3>Upload this file</h3> <h3>Upload each file</h3>
<div class="http-verification-info file-preview"> <div class="js-acme-http">
<div class="paper-fold"></div> <div class="http-verification-info file-preview">
<div> <div class="paper-fold"></div>
<div class="file-ver-info-header">FILENAME</div> <div>
<pre class="js-acme-ver-file-location">...loading</pre> <div class="file-ver-info-header">FILENAME</div>
</div> <pre class="js-acme-ver-file-location">...loading</pre>
<hr> </div>
<div> <hr>
<div class="file-ver-info-header">CONTENTS</div> <div>
<pre class="js-acme-ver-content">...loading</pre> <div class="file-ver-info-header">CONTENTS</div>
<pre class="js-acme-ver-content">...loading</pre>
</div>
<div class="download-file">
<svg class="mdicon icon-download" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<use xlink:href="#svg-download"></use>
</svg>
<a class="js-download-verify-link" href="data:text/octet-stream;base64,SGVsbG8gV29ybGQuLi4=" download="hello.txt" target="_blank">
Download
</a>
</div>
<hr>
<div>
<div class="file-ver-info-header">LOCATION</div>
<pre class="js-acme-ver-uri">..loading</pre>
</div>
</div> </div>
<br>
</div> </div>
<div class="download-file">
<svg class="mdicon icon-download" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<use xlink:href="#svg-download"></use>
</svg>
<a class="js-download-verify-link" href="data:text/octet-stream;base64,SGVsbG8gV29ybGQuLi4=" download="hello.txt" target="_blank">
Download
</a>
</div>
<h3>To this location</h3>
<div class="js-acme-ver-uri" class="acme-ver-uri">..loading</div>
</div> </div>
<div class="js-acme-verification-dns-01"> <div class="js-acme-verification-dns-01">
<h3>Set this DNS Record</h3> <h3>Set each DNS Record</h3>
<div class="acme-ver-dns-label">Hostname</div> <div class="js-acme-dns">
<div class="js-acme-ver-hostname">loading...</div> <div class="acme-ver-dns-label">TXT Host</div>
<div class="acme-ver-dns-label">TXT Host</div> <div class="js-acme-ver-txt-host">loading...</div>
<div class="js-acme-ver-txt-host">loading...</div> <div class="acme-ver-dns-label">TXT Value</div>
<div class="acme-ver-dns-label">TXT Value</div> <div class="js-acme-ver-txt-value">loading...</div>
<div class="js-acme-ver-txt-value">loading...</div> <br>
</div>
</div> </div>
</div> </div>
<div class="js-acme-wildcard-challenges"> <div class="js-acme-wildcard-challenges">
<div class="js-acme-wildcard"> <div class="js-acme-verification-wildcard">
<div class="js-acme-verification-wildcard"> <h3>Set each DNS Record (for wildcards)</h3>
<h3>Set this DNS Record</h3> <div class="js-acme-wildcard">
<div class="acme-ver-dns-label">Hostname</div>
<div class="js-acme-ver-hostname">loading...</div>
<div class="acme-ver-dns-label">TXT Host</div> <div class="acme-ver-dns-label">TXT Host</div>
<div class="js-acme-ver-txt-host">loading...</div> <div class="js-acme-ver-txt-host">loading...</div>
<div class="acme-ver-dns-label">TXT Value</div> <div class="acme-ver-dns-label">TXT Value</div>
<div class="js-acme-ver-txt-value">loading...</div> <div class="js-acme-ver-txt-value">loading...</div>
<br>
</div> </div>
</div> </div>
</div> </div>
@ -291,7 +298,7 @@
</div> </div>
<div> <div>
<h3>node.js https server example</h3> <h3>node.js https server example</h3>
<pre><code>'use strict'; <pre><code> 'use strict';
var https = require('https'); var https = require('https');
var server = https.createServer({ var server = https.createServer({

48
app/js/greenlock.js

@ -226,7 +226,7 @@
info.domains = $qs('.js-acme-domains').value.replace(/https?:\/\//g, ' ').replace(/[,+]/g, ' ').trim().split(/\s+/g); info.domains = $qs('.js-acme-domains').value.replace(/https?:\/\//g, ' ').replace(/[,+]/g, ' ').trim().split(/\s+/g);
info.identifiers = info.domains.map(function (hostname) { info.identifiers = info.domains.map(function (hostname) {
return { type: 'dns', value: hostname.toLowerCase().trim() }; return { type: 'dns', value: hostname.toLowerCase().trim() };
}).slice(0,1); //Disable multiple values for now. We'll just take the first and work with it. });
info.identifiers.sort(function (a, b) { info.identifiers.sort(function (a, b) {
if (a === b) { return 0; } if (a === b) { return 0; }
if (a < b) { return 1; } if (a < b) { return 1; }
@ -255,6 +255,8 @@
info.agree = $qs('.js-acme-account-tos').checked; info.agree = $qs('.js-acme-account-tos').checked;
//info.greenlockAgree = $qs('.js-gl-tos').checked; //info.greenlockAgree = $qs('.js-gl-tos').checked;
info.domains = info.identifiers.map(function (ident) { return ident.value; }); info.domains = info.identifiers.map(function (ident) { return ident.value; });
console.log("domains:");
console.log(info.domains);
// TODO ping with version and account creation // TODO ping with version and account creation
setTimeout(saveContact, 100, email, info.domains); setTimeout(saveContact, 100, email, info.domains);
@ -267,6 +269,8 @@
} }
} }
$qs('.js-account-next').disabled = true;
return getAccountKeypair(email).then(function (jwk) { return getAccountKeypair(email).then(function (jwk) {
// TODO save account id rather than always retrieving it? // TODO save account id rather than always retrieving it?
return acme.accounts.create({ return acme.accounts.create({
@ -313,6 +317,15 @@
, 'wildcard': '.js-acme-verification-wildcard' , 'wildcard': '.js-acme-verification-wildcard'
}; };
*/ */
var $httpList = $qs('.js-acme-http');
var $dnsList = $qs('.js-acme-dns');
var $wildList = $qs('.js-acme-wildcard');
var httpTpl = $httpList.innerHTML;
var dnsTpl = $dnsList.innerHTML;
var wildTpl = $wildList.innerHTML;
$httpList.innerHTML = '';
$dnsList.innerHTML = '';
$wildList.innerHTML = '';
claims.forEach(function (claim) { claims.forEach(function (claim) {
console.log("Challenge (claim):"); console.log("Challenge (claim):");
@ -339,30 +352,33 @@
console.log(data); console.log(data);
console.log(''); console.log('');
var verification; var verification = document.createElement("div");
if (claim.wildcard) { if (claim.wildcard) {
obj.wildcard.push(data); obj.wildcard.push(data);
verification = $qs(".js-acme-verification-wildcard"); verification.innerHTML = wildTpl;
verification.querySelector(".js-acme-ver-hostname").innerHTML = data.hostname; //verification.querySelector(".js-acme-ver-hostname").innerHTML = data.hostname;
verification.querySelector(".js-acme-ver-txt-host").innerHTML = data.dnsHost; verification.querySelector(".js-acme-ver-txt-host").innerHTML = data.dnsHost;
verification.querySelector(".js-acme-ver-txt-value").innerHTML = data.dnsAnswer; verification.querySelector(".js-acme-ver-txt-value").innerHTML = data.dnsAnswer;
$wildList.appendChild(verification);
} else if(obj[data.type]) { } else if(obj[data.type]) {
obj[data.type].push(data); obj[data.type].push(data);
if ('dns-01' === data.type) { if ('dns-01' === data.type) {
verification = $qs(".js-acme-verification-dns-01"); verification.innerHTML = dnsTpl;
verification.querySelector(".js-acme-ver-hostname").innerHTML = data.hostname; //verification.querySelector(".js-acme-ver-hostname").innerHTML = data.hostname;
verification.querySelector(".js-acme-ver-txt-host").innerHTML = data.dnsHost; verification.querySelector(".js-acme-ver-txt-host").innerHTML = data.dnsHost;
verification.querySelector(".js-acme-ver-txt-value").innerHTML = data.dnsAnswer; verification.querySelector(".js-acme-ver-txt-value").innerHTML = data.dnsAnswer;
$dnsList.appendChild(verification);
} else if ('http-01' === data.type) { } else if ('http-01' === data.type) {
$qs(".js-acme-ver-file-location").innerHTML = data.httpPath.split("/").slice(-1); verification.innerHTML = httpTpl;
$qs(".js-acme-ver-content").innerHTML = data.httpAuth; verification.querySelector(".js-acme-ver-file-location").innerHTML = data.httpPath.split("/").slice(-1);
$qs(".js-acme-ver-uri").innerHTML = data.httpPath; verification.querySelector(".js-acme-ver-content").innerHTML = data.httpAuth;
$qs(".js-download-verify-link").href = verification.querySelector(".js-acme-ver-uri").innerHTML = data.httpPath;
verification.querySelector(".js-download-verify-link").href =
"data:text/octet-stream;base64," + window.btoa(data.httpAuth); "data:text/octet-stream;base64," + window.btoa(data.httpAuth);
$qs(".js-download-verify-link").download = data.httpPath.split("/").slice(-1); verification.querySelector(".js-download-verify-link").download = data.httpPath.split("/").slice(-1);
$httpList.appendChild(verification);
} }
} }
}); });
@ -455,9 +471,6 @@
$qs('.js-acme-form-download').hidden = false; $qs('.js-acme-form-download').hidden = false;
}; };
// The kickoff
steps[1]();
var params = new URLSearchParams(window.location.search); var params = new URLSearchParams(window.location.search);
var apiType = params.get('acme-api-type') || "staging-v02"; var apiType = params.get('acme-api-type') || "staging-v02";
@ -479,7 +492,7 @@
$el.addEventListener('change', updateChallengeType); $el.addEventListener('change', updateChallengeType);
}); });
if(params.has('acme-domains')) { if (params.has('acme-domains')) {
console.log("acme-domains param: ", params.get('acme-domains')); console.log("acme-domains param: ", params.get('acme-domains'));
$qs('.js-acme-domains').value = params.get('acme-domains'); $qs('.js-acme-domains').value = params.get('acme-domains');
@ -496,6 +509,9 @@
$qs('body').hidden = false; $qs('body').hidden = false;
// The kickoff
steps[1]();
return testKeypairSupport().then(function (rsaSupport) { return testKeypairSupport().then(function (rsaSupport) {
if (rsaSupport) { if (rsaSupport) {
return true; return true;

Loading…
Cancel
Save