Compare commits
No commits in common. "009e0dc1fb949b470cca865291db381348eaf06d" and "914ec5a516f19b1aa767240124da4534ec237b06" have entirely different histories.
009e0dc1fb
...
914ec5a516
57
app.js
57
app.js
|
@ -122,7 +122,6 @@
|
||||||
$('.js-loading').hidden = false;
|
$('.js-loading').hidden = false;
|
||||||
var acme = ACME.create({
|
var acme = ACME.create({
|
||||||
Keypairs: Keypairs
|
Keypairs: Keypairs
|
||||||
, CSR: CSR
|
|
||||||
});
|
});
|
||||||
acme.init('https://acme-staging-v02.api.letsencrypt.org/directory').then(function (result) {
|
acme.init('https://acme-staging-v02.api.letsencrypt.org/directory').then(function (result) {
|
||||||
console.log('acme result', result);
|
console.log('acme result', result);
|
||||||
|
@ -150,7 +149,16 @@
|
||||||
$('form.js-csr').addEventListener('submit', function (ev) {
|
$('form.js-csr').addEventListener('submit', function (ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
generateCsr();
|
var domains = ($('.js-domains').value||'example.com').split(/[, ]+/g);
|
||||||
|
var privJwk = JSON.parse($('.js-jwk').innerText).private;
|
||||||
|
return CSR({ jwk: privJwk, domains: domains }).then(function (pem) {
|
||||||
|
// Verify with https://www.sslshopper.com/csr-decoder.html
|
||||||
|
console.log('CSR:');
|
||||||
|
console.log(pem);
|
||||||
|
|
||||||
|
console.log('CSR info:');
|
||||||
|
console.log(CSR._info(pem));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('form.js-acme-order').addEventListener('submit', function (ev) {
|
$('form.js-acme-order').addEventListener('submit', function (ev) {
|
||||||
|
@ -161,14 +169,17 @@
|
||||||
var email = accountStuff.email;
|
var email = accountStuff.email;
|
||||||
var acme = accountStuff.acme;
|
var acme = accountStuff.acme;
|
||||||
|
|
||||||
|
return Keypairs.generate({
|
||||||
|
kty: $('input[name="kty"]:checked').value
|
||||||
|
, namedCurve: $('input[name="ec-crv"]:checked').value
|
||||||
|
, modulusLength: $('input[name="rsa-len"]:checked').value
|
||||||
|
}).then(function (pair) {
|
||||||
|
console.log('domain keypair:', pair);
|
||||||
var domains = ($('.js-domains').value||'example.com').split(/[, ]+/g);
|
var domains = ($('.js-domains').value||'example.com').split(/[, ]+/g);
|
||||||
return getDomainPrivkey().then(function () {
|
|
||||||
return acme.certificates.create({
|
return acme.certificates.create({
|
||||||
accountKeypair: { privateKeyJwk: privJwk }
|
accountKeypair: { privateKeyJwk: privJwk }
|
||||||
, account: account
|
, account: account
|
||||||
//, domainKeypair: { privateKeyJwk: accountStuff.domainPrivateJwk }
|
, domainKeypair: { privateKeyJwk: pair.private }
|
||||||
, csr: accountStuff.csr
|
|
||||||
, email: email
|
, email: email
|
||||||
, domains: domains
|
, domains: domains
|
||||||
, agreeToTerms: checkTos
|
, agreeToTerms: checkTos
|
||||||
|
@ -215,8 +226,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
, challengeTypes: [$('input[name="acme-challenge-type"]:checked').value]
|
, challengeTypes: [$('input[name="acme-challenge-type"]:checked').value]
|
||||||
}).catch(function (err) {
|
|
||||||
window.alert("failed! " + err.message || JSON.stringify(err));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -224,37 +233,5 @@
|
||||||
$('.js-generate').hidden = false;
|
$('.js-generate').hidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDomainPrivkey() {
|
|
||||||
if (accountStuff.domainPrivateJwk) { return Promise.resolve(accountStuff.domainPrivateJwk); }
|
|
||||||
return Keypairs.generate({
|
|
||||||
kty: $('input[name="kty"]:checked').value
|
|
||||||
, namedCurve: $('input[name="ec-crv"]:checked').value
|
|
||||||
, modulusLength: $('input[name="rsa-len"]:checked').value
|
|
||||||
}).then(function (pair) {
|
|
||||||
console.log('domain keypair:', pair);
|
|
||||||
accountStuff.domainPrivateJwk = pair.private;
|
|
||||||
return pair.private;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateCsr() {
|
|
||||||
var domains = ($('.js-domains').value||'example.com').split(/[, ]+/g);
|
|
||||||
//var privJwk = JSON.parse($('.js-jwk').innerText).private;
|
|
||||||
return getDomainPrivkey().then(function (privJwk) {
|
|
||||||
accountStuff.domainPrivateJwk = privJwk;
|
|
||||||
return CSR({ jwk: privJwk, domains: domains }).then(function (pem) {
|
|
||||||
// Verify with https://www.sslshopper.com/csr-decoder.html
|
|
||||||
accountStuff.csr = pem;
|
|
||||||
console.log('CSR:');
|
|
||||||
console.log(pem);
|
|
||||||
|
|
||||||
console.log('CSR info:');
|
|
||||||
console.log(CSR._info(pem));
|
|
||||||
|
|
||||||
return pem;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('load', run);
|
window.addEventListener('load', run);
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -848,10 +848,10 @@ ACME.create = function create(me) {
|
||||||
if (!me) { me = {}; }
|
if (!me) { me = {}; }
|
||||||
// me.debug = true;
|
// me.debug = true;
|
||||||
me.challengePrefixes = ACME.challengePrefixes;
|
me.challengePrefixes = ACME.challengePrefixes;
|
||||||
me.Keypairs = me.Keypairs || exports.Keypairs || require('keypairs').Keypairs;
|
me.Keypairs = me.Keypairs || me.RSA || require('rsa-compat').RSA;
|
||||||
me.CSR = me.CSR || exports.cSR || require('CSR').CSR;
|
me.CSR = me.CSR || require('CSR').CSR;
|
||||||
me._nonces = [];
|
me._nonces = [];
|
||||||
me._canUse = {};
|
me._canCheck = {};
|
||||||
if (!me._baseUrl) {
|
if (!me._baseUrl) {
|
||||||
me._baseUrl = "";
|
me._baseUrl = "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ CSR._info = function (der) {
|
||||||
// TODO utf8
|
// TODO utf8
|
||||||
return Enc.bufToBin(name.value);
|
return Enc.bufToBin(name.value);
|
||||||
});
|
});
|
||||||
})[0];
|
});
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -186,6 +186,10 @@ Keypairs.signJws = function (opts) {
|
||||||
, signature: Enc.bufToUrlBase64(buf)
|
, signature: Enc.bufToUrlBase64(buf)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('Signed Base64 Msg:');
|
||||||
|
console.log(JSON.stringify(signedMsg, null, 2));
|
||||||
|
|
||||||
|
console.log('msg:', msg);
|
||||||
return signedMsg;
|
return signedMsg;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -259,6 +263,7 @@ Keypairs._import = function (opts) {
|
||||||
opts.jwk.ext = true;
|
opts.jwk.ext = true;
|
||||||
opts.jwk.key_ops = ops;
|
opts.jwk.key_ops = ops;
|
||||||
|
|
||||||
|
console.log('jwk', opts.jwk);
|
||||||
return window.crypto.subtle.importKey(
|
return window.crypto.subtle.importKey(
|
||||||
"jwk"
|
"jwk"
|
||||||
, opts.jwk
|
, opts.jwk
|
||||||
|
|
Loading…
Reference in New Issue