register multiple challenges
This commit is contained in:
parent
bb211e8f42
commit
9517980889
|
@ -122,7 +122,8 @@ function leAgree(opts, agreeCb) {
|
|||
le = LE.create({
|
||||
server: LE.stagingServerUrl // or LE.productionServerUrl
|
||||
, store: leStore // handles saving of config, accounts, and certificates
|
||||
, challenge: leChallenge // handles /.well-known/acme-challege keys and tokens
|
||||
, challenges: { 'http-01': leChallenge } // handles /.well-known/acme-challege keys and tokens
|
||||
, challengeType: 'http-01' // default to this challenge type
|
||||
, agreeToTerms: leAgree // hook to allow user to view and accept LE TOS
|
||||
, debug: false
|
||||
});
|
||||
|
@ -132,7 +133,7 @@ le = LE.create({
|
|||
// app.use('/', le.middleware());
|
||||
//
|
||||
// Otherwise you should see the test file for usage of this:
|
||||
// le.challenge.get(opts.domain, key, val, done)
|
||||
// le.challenges['http-01'].get(opts.domain, key, val, done)
|
||||
|
||||
|
||||
|
||||
|
@ -160,7 +161,7 @@ le.check({ domains: [ 'example.com' ] }).then(function (results) {
|
|||
}, function (err) {
|
||||
|
||||
// Note: you must either use le.middleware() with express,
|
||||
// manually use le.challenge.get(opts, domain, key, val, done)
|
||||
// manually use le.challenges['http-01'].get(opts, domain, key, val, done)
|
||||
// or have a webserver running and responding
|
||||
// to /.well-known/acme-challenge at `webrootPath`
|
||||
console.error('[Error]: node-letsencrypt/examples/standalone');
|
||||
|
|
51
index.js
51
index.js
|
@ -13,6 +13,7 @@ LE.defaults = {
|
|||
|
||||
, rsaKeySize: ACME.rsaKeySize || 2048
|
||||
, challengeType: ACME.challengeType || 'http-01'
|
||||
, challengeTypes: ACME.challengeTypes || [ 'http-01', 'tls-sni-01', 'dns-01' ]
|
||||
|
||||
, acmeChallengePrefix: ACME.acmeChallengePrefix
|
||||
};
|
||||
|
@ -28,6 +29,9 @@ LE._undefined = {
|
|||
acme: u
|
||||
, store: u
|
||||
, challenge: u
|
||||
, challenges: u
|
||||
, sni: u
|
||||
, httpsOptions: u
|
||||
|
||||
, register: u
|
||||
, check: u
|
||||
|
@ -57,9 +61,29 @@ LE.create = function (le) {
|
|||
|
||||
le.acme = le.acme || ACME.create({ debug: le.debug });
|
||||
le.store = le.store || require('le-store-certbot').create({ debug: le.debug });
|
||||
le.challenge = le.challenge || require('le-challenge-fs').create({ debug: le.debug });
|
||||
le.core = require('./lib/core');
|
||||
|
||||
if (!le.challenges) {
|
||||
le.challenges = {};
|
||||
}
|
||||
if (!le.challenges['http-01']) {
|
||||
le.challenges['http-01'] = require('le-challenge-fs').create({ debug: le.debug });
|
||||
}
|
||||
if (!le.challenges['tls-sni-01']) {
|
||||
le.challenges['tls-sni-01'] = le.challenges['http-01'];
|
||||
}
|
||||
if (!le.challenges['dns-01']) {
|
||||
try {
|
||||
le.challenges['dns-01'] = require('le-challenge-ddns').create({ debug: le.debug });
|
||||
} catch(e) {
|
||||
try {
|
||||
le.challenges['dns-01'] = require('le-challenge-dns').create({ debug: le.debug });
|
||||
} catch(e) {
|
||||
// not yet implemented
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
le = LE._undefine(le);
|
||||
le.acmeChallengePrefix = LE.acmeChallengePrefix;
|
||||
le.rsaKeySize = le.rsaKeySize || LE.rsaKeySize;
|
||||
|
@ -106,16 +130,33 @@ LE.create = function (le) {
|
|||
}
|
||||
});
|
||||
|
||||
if (le.challenge.create) {
|
||||
le.challenge = le.challenge.create(le);
|
||||
LE.challengeTypes.forEach(function (challengeType) {
|
||||
if (le.challenges[challengeType].create) {
|
||||
le.challenges[challengeType] = le.challenges[challengeType].create(le);
|
||||
}
|
||||
le.challenge = PromiseA.promisifyAll(le.challenge);
|
||||
le._challengeOpts = le.challenge.getOptions();
|
||||
le.challenges[challengeType] = PromiseA.promisifyAll(le.challenges[challengeType]);
|
||||
le['_challengeOpts_' + challengeType] = le.challenges[challengeType].getOptions();
|
||||
Object.keys(le._challengeOpts).forEach(function (key) {
|
||||
if (!(key in le)) {
|
||||
le[key] = le._challengeOpts[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//
|
||||
// Backwards compat until we fix le.challenges to be per-request
|
||||
//
|
||||
if (le.challenge) {
|
||||
console.warn("Deprecated use of le.challenge. Use le.challenges['" + LE.challengeType + "'] instead.");
|
||||
// TODO le.challenges[le.challengeType] = le.challenge
|
||||
if (le.challenge.create) {
|
||||
le.challenge = le.challenge.create(le);
|
||||
}
|
||||
}
|
||||
else {
|
||||
le.challenge = le.challenge[le.challengeType];
|
||||
}
|
||||
le._challengeOpts = le.challenge.getOptions();
|
||||
|
||||
le.sni = le.sni || null;
|
||||
if (!le.httpsOptions) {
|
||||
|
|
Loading…
Reference in New Issue