updates
This commit is contained in:
parent
9f5b52a7be
commit
4767d14517
|
@ -150,6 +150,7 @@ LeCore.acmeChallengePrefix // /.well-known/acme-challenge/
|
||||||
LeCore.configDir // /etc/letsencrypt/
|
LeCore.configDir // /etc/letsencrypt/
|
||||||
LeCore.logsDir // /var/log/letsencrypt/
|
LeCore.logsDir // /var/log/letsencrypt/
|
||||||
LeCore.workDir // /var/lib/letsencrypt/
|
LeCore.workDir // /var/lib/letsencrypt/
|
||||||
|
LeCore.knownEndpoints // new-authz, new-cert, new-reg, revoke-cert
|
||||||
|
|
||||||
|
|
||||||
// HTTP Client Helpers
|
// HTTP Client Helpers
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*!
|
||||||
|
* letiny-core
|
||||||
|
* Copyright(c) 2015 AJ ONeal <aj@daplie.com> https://daplie.com
|
||||||
|
* Apache-2.0 OR MIT (and hence also MPL 2.0)
|
||||||
|
*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports.create = function (deps) {
|
||||||
|
var request = deps.request;
|
||||||
|
var knownUrls = deps.LeCore.knownEndpoints;
|
||||||
|
|
||||||
|
function getAcmeUrls(acmeDiscoveryUrl, cb) {
|
||||||
|
|
||||||
|
// TODO check response header on request for cache time
|
||||||
|
return request({
|
||||||
|
url: acmeDiscoveryUrl
|
||||||
|
}, function (err, resp) {
|
||||||
|
if (err) {
|
||||||
|
cb(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = resp.body;
|
||||||
|
|
||||||
|
if ('string' === typeof data) {
|
||||||
|
try {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
} catch(e) {
|
||||||
|
cb(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (4 !== Object.keys(data).length) {
|
||||||
|
console.warn("This Let's Encrypt / ACME server has been updated with urls that this client doesn't understand");
|
||||||
|
console.warn(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!knownUrls.every(function (url) {
|
||||||
|
return data[url];
|
||||||
|
})) {
|
||||||
|
console.warn("This Let's Encrypt / ACME server is missing urls that this client may need.");
|
||||||
|
console.warn(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
newAuthz: data['new-authz']
|
||||||
|
, newCert: data['new-cert']
|
||||||
|
, newReg: data['new-reg']
|
||||||
|
, revokeCert: data['revoke-cert']
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return getAcmeUrls;
|
||||||
|
};
|
4
node.js
4
node.js
|
@ -1,5 +1,5 @@
|
||||||
/*!
|
/*!
|
||||||
* letsencrypt-core
|
* letiny-core
|
||||||
* Copyright(c) 2015 AJ ONeal <aj@daplie.com> https://daplie.com
|
* Copyright(c) 2015 AJ ONeal <aj@daplie.com> https://daplie.com
|
||||||
* Apache-2.0 OR MIT (and hence also MPL 2.0)
|
* Apache-2.0 OR MIT (and hence also MPL 2.0)
|
||||||
*/
|
*/
|
||||||
|
@ -9,6 +9,7 @@ function create(deps) {
|
||||||
var LeCore = {};
|
var LeCore = {};
|
||||||
|
|
||||||
LeCore.leCrypto = deps.leCrypto;
|
LeCore.leCrypto = deps.leCrypto;
|
||||||
|
LeCore.getAcmeUrls = require('./lib/get-acme-urls').create(deps);
|
||||||
deps.Acme = LeCore.Acme = require('./lib/acme-client').create(deps);
|
deps.Acme = LeCore.Acme = require('./lib/acme-client').create(deps);
|
||||||
LeCore.registerNewAccount = require('./lib/register-new-account').create(deps);
|
LeCore.registerNewAccount = require('./lib/register-new-account').create(deps);
|
||||||
LeCore.getCertificate = require('./lib/get-certificate').create(deps);
|
LeCore.getCertificate = require('./lib/get-certificate').create(deps);
|
||||||
|
@ -22,6 +23,7 @@ function create(deps) {
|
||||||
LeCore.configDir = "/etc/letsencrypt/";
|
LeCore.configDir = "/etc/letsencrypt/";
|
||||||
LeCore.logsDir = "/var/log/letsencrypt/";
|
LeCore.logsDir = "/var/log/letsencrypt/";
|
||||||
LeCore.workDir = "/var/lib/letsencrypt/";
|
LeCore.workDir = "/var/lib/letsencrypt/";
|
||||||
|
LeCore.knownEndpoints = ['new-authz', 'new-cert', 'new-reg', 'revoke-cert'];
|
||||||
|
|
||||||
return LeCore;
|
return LeCore;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue