diff --git a/example/letsencrypt.js b/example/letsencrypt.js index 6490ff1..28f1adf 100644 --- a/example/letsencrypt.js +++ b/example/letsencrypt.js @@ -41,7 +41,7 @@ function init() { }); } -function getPrivateKeys() { +function getPrivateKeys(cb) { console.log('Generating Account Keypair'); LeCore.leCrypto.generateRsaKeypair(2048, 65537, function (err, pems) { @@ -50,7 +50,7 @@ function getPrivateKeys() { LeCore.leCrypto.generateRsaKeypair(2048, 65537, function (err, pems) { domainPrivateKeyPem = pems.privateKeyPem; - runDemo(); + cb(); }); }); } diff --git a/lib/get-acme-urls.js b/lib/get-acme-urls.js index 87d14c5..e750583 100644 --- a/lib/get-acme-urls.js +++ b/lib/get-acme-urls.js @@ -10,6 +10,8 @@ module.exports.create = function (deps) { var knownUrls = deps.LeCore.knownEndpoints; function getAcmeUrls(acmeDiscoveryUrl, cb) { + console.log('acmeDiscoveryUrl'); + console.log(acmeDiscoveryUrl); // TODO check response header on request for cache time return request({ @@ -43,12 +45,12 @@ module.exports.create = function (deps) { console.warn(data); } - return { + cb(null, { newAuthz: data['new-authz'] , newCert: data['new-cert'] , newReg: data['new-reg'] , revokeCert: data['revoke-cert'] - }; + }); }); } diff --git a/node.js b/node.js index 69d3b8b..80dc037 100644 --- a/node.js +++ b/node.js @@ -8,12 +8,6 @@ function create(deps) { var LeCore = {}; - LeCore.leCrypto = deps.leCrypto; - LeCore.getAcmeUrls = require('./lib/get-acme-urls').create(deps); - deps.Acme = LeCore.Acme = require('./lib/acme-client').create(deps); - LeCore.registerNewAccount = require('./lib/register-new-account').create(deps); - LeCore.getCertificate = require('./lib/get-certificate').create(deps); - // Note: these are NOT DEFAULTS // They are de facto standards that you may // or may not use in your implementation @@ -25,6 +19,15 @@ function create(deps) { LeCore.workDir = "/var/lib/letsencrypt/"; LeCore.knownEndpoints = ['new-authz', 'new-cert', 'new-reg', 'revoke-cert']; + deps.LeCore = LeCore; + deps.Acme = LeCore.Acme = require('./lib/acme-client').create(deps); + + LeCore.getAcmeUrls = require('./lib/get-acme-urls').create(deps); + LeCore.registerNewAccount = require('./lib/register-new-account').create(deps); + LeCore.getCertificate = require('./lib/get-certificate').create(deps); + + LeCore.leCrypto = deps.leCrypto; + return LeCore; }