From 40200e4dc59dc60846b0eb9527f7d1af60bbde26 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 1 May 2018 08:15:41 +0000 Subject: [PATCH] ugly first steps --- index.html | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++- js/app.js | 55 ++++++++++++++++++++- js/bacme.js | 18 ++++--- 3 files changed, 196 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 260e34b..4c968ea 100644 --- a/index.html +++ b/index.html @@ -3,13 +3,143 @@ Greenlock™ -
+ + + - +
+ +
+ + + + + advanced (use existing account) + +
+ + +
+ + + + + Verify Domains & Sub-Domains: + + + + + + + + + + + + + + + + +
HostnameFile LocationFile Contents
example.com.well-known/acme-challenge/xxxsec.ret
+ + + + + + + + + + + + + + + + +
HostnameTXT HostTXT Value
example.com_acme-challenge.example.com4A54
+ +
+ Verify Wildcard Domains: + + + + + + + + + + + + + + + + +
HostnameTXT HostTXT Value
example.com_acme-challenge.example.com4A54
+
+ + +
+ + +
+ Verifying Domains... + + + + + + + + + + + + + + + + +
HostnameTypePass
example.comhttp-01-
+ + advanced (use existing keypair for domain) + + +
+ + +
+ + + + + + + + + + + + + + + Advanced (copy and paste) + + +
+ + diff --git a/js/app.js b/js/app.js index 8c0a810..73d30ee 100644 --- a/js/app.js +++ b/js/app.js @@ -1,6 +1,57 @@ (function () { 'use strict'; - //window.document.querySelector('.js-acme-directory-url').value = 'https://acme-v02.api.letsencrypt.org/directory'; - window.document.querySelector('.js-acme-directory-url').value = 'https://acme-staging-v02.api.letsencrypt.org/directory'; + var $qs = function (s) { return window.document.querySelector(s); }; + var $qsa = function (s) { return window.document.querySelectorAll(s); }; + var info = {}; + var steps = {}; + var i = 1; + + //$qs('.js-acme-directory-url').value = 'https://acme-v02.api.letsencrypt.org/directory'; + $qs('.js-acme-directory-url').value = 'https://acme-staging-v02.api.letsencrypt.org/directory'; + + function hideForms() { + $qsa('.js-acme-form').forEach(function (el) { + el.hidden = true; + }); + } + + $qs('.js-acme-form-domains').addEventListener('submit', function (ev) { + ev.preventDefault(); + info.identifiers = $qs('.js-acme-domains').value.split(/,/g).map(function (hostname) { + return { type: 'dns', value: hostname.trim() }; + }); + + return BACME.directory($qs('.js-acme-directory-url').value).then(function () { + i += 1; + steps[i](); + }); + }); + + steps[1] = function () { + hideForms(); + $qs('.js-acme-form-domains').hidden = false; + }; + + steps[2] = function () { + hideForms(); + $qs('.js-acme-form-account').hidden = false; + }; + + steps[3] = function () { + hideForms(); + $qs('.js-acme-form-challenges').hidden = false; + }; + + steps[4] = function () { + hideForms(); + $qs('.js-acme-form-poll').hidden = false; + } + + steps[5] = function () { + hideForms(); + $qs('.js-acme-form-download').hidden = false; + } + + steps[1](); }()); diff --git a/js/bacme.js b/js/bacme.js index 7054187..6f68173 100644 --- a/js/bacme.js +++ b/js/bacme.js @@ -8,13 +8,13 @@ var webCrypto = exports.crypto; var directoryUrl = 'https://acme-staging-v02.api.letsencrypt.org/directory'; var directory; -var nonceUrl = directory.newNonce || 'https://acme-staging-v02.api.letsencrypt.org/acme/new-nonce'; +var nonceUrl; var nonce; var accountKeypair; var accountJwk; -var accountUrl = directory.newAccount; +var accountUrl; var signedAccount; BACME.challengePrefixes = { @@ -38,6 +38,9 @@ BACME.directory = function (url) { BACME._logHeaders(resp); return resp.json().then(function (body) { directory = body; + nonceUrl = directory.newNonce || 'https://acme-staging-v02.api.letsencrypt.org/acme/new-nonce'; + accountUrl = directory.newAccount || 'https://acme-staging-v02.api.letsencrypt.org/acme/new-account'; + orderUrl = directory.newOrder || "https://acme-staging-v02.api.letsencrypt.org/acme/new-order"; BACME._logBody(body); return body; }); @@ -169,7 +172,7 @@ BACME.accounts.set = function () { }); }; -var orderUrl = directory.newOrder || "https://acme-staging-v02.api.letsencrypt.org/acme/new-order"; +var orderUrl; var signedOrder; BACME.orders = {}; @@ -305,7 +308,8 @@ BACME.challenges['http-01'] = function () { path: httpPath , value: keyAuth }; -}); +}; + BACME.challenges['dns-01'] = function () { return window.crypto.subtle.digest( { name: "SHA-256", } @@ -326,7 +330,7 @@ BACME.challenges['dns-01'] = function () { return { type: 'TXT' , host: dnsRecord - , answer: dnsAuth; + , answer: dnsAuth }; }); }; @@ -424,13 +428,13 @@ BACME.domains.generateKeypair = function () { }); }; -BACME.order.generateCsr = function (keypair, domains) { +BACME.orders.generateCsr = function (keypair, domains) { return Promise.resolve(CSR.generate(keypair, domains)); }; var certificateUrl; -BACME.order.finalize = function () { +BACME.orders.finalize = function () { var payload64 = jsto64( { csr: csr } );