2019-04-03 02:59:11 +00:00
|
|
|
# le-challenge-dns
|
2016-10-14 19:39:54 +00:00
|
|
|
|
2019-04-02 05:34:35 +00:00
|
|
|
| A [Root](https://rootprojects.org) Project
|
2018-05-01 20:14:15 +00:00
|
|
|
| [greenlock.js](https://git.coolaj86.com/coolaj86/greenlock.js) (library)
|
|
|
|
| [greenlock-express.js](https://git.coolaj86.com/coolaj86/greenlock-express.js)
|
|
|
|
| [greenlock-cli.js](https://git.coolaj86.com/coolaj86/greenlock-cli.js)
|
|
|
|
| [acme-v2.js](https://git.coolaj86.com/coolaj86/acme-v2.js)
|
|
|
|
|
|
|
|
|
|
2018-05-13 01:22:09 +00:00
|
|
|
A manual (interactive CLI) dns-based strategy for greenlock.js for setting, retrieving,
|
2016-10-14 19:39:54 +00:00
|
|
|
and clearing ACME DNS-01 challenges issued by the ACME server
|
|
|
|
|
|
|
|
Prints out a subdomain record for `_acme-challenge` with `keyAuthDigest`
|
|
|
|
to be tested by the ACME server.
|
|
|
|
|
|
|
|
You can then update your DNS manually by whichever method you use and then
|
|
|
|
press [enter] to continue the process.
|
|
|
|
|
|
|
|
```
|
|
|
|
_acme-challenge.example.com TXT xxxxxxxxxxxxxxxx TTL 60
|
|
|
|
```
|
|
|
|
|
2019-04-03 02:59:11 +00:00
|
|
|
## Install
|
2016-10-14 19:39:54 +00:00
|
|
|
|
|
|
|
```bash
|
2019-04-03 02:59:11 +00:00
|
|
|
npm install --save le-challenge-dns@3.x
|
2016-10-14 19:39:54 +00:00
|
|
|
```
|
|
|
|
|
2019-04-03 02:59:11 +00:00
|
|
|
If you have `greenlock@v2.6` or lower, you'll need the old `le-challenge-dns@3.x` instead.
|
|
|
|
|
|
|
|
## Usage
|
2016-10-14 19:39:54 +00:00
|
|
|
|
2018-05-13 01:22:09 +00:00
|
|
|
The challenge can be set globally like this:
|
|
|
|
|
2019-04-03 02:59:11 +00:00
|
|
|
```js
|
2016-10-14 19:39:54 +00:00
|
|
|
var leChallengeDns = require('le-challenge-dns').create({
|
|
|
|
debug: false
|
|
|
|
});
|
|
|
|
|
2018-05-13 01:22:09 +00:00
|
|
|
var Greenlock = require('greenlock');
|
2016-10-14 19:39:54 +00:00
|
|
|
|
2018-05-13 01:22:09 +00:00
|
|
|
Greenlock.create({
|
2019-04-03 02:59:11 +00:00
|
|
|
...
|
2016-10-14 19:39:54 +00:00
|
|
|
, challenges: {
|
|
|
|
'dns-01': leChallengeDns
|
|
|
|
}
|
2019-04-03 02:59:11 +00:00
|
|
|
, approveDomains: [ 'example.com', '*.example.com' ]
|
2016-10-14 19:39:54 +00:00
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2018-05-13 01:22:09 +00:00
|
|
|
In can also be set in the `approveDomains` callback instead, like this:
|
|
|
|
|
2019-04-03 02:59:11 +00:00
|
|
|
```js
|
|
|
|
function approveDomains(opts, certs, cb) {
|
|
|
|
...
|
|
|
|
opts.subject = 'example.com'
|
|
|
|
opts.domains = [ 'example.com', '*.example.com' ];
|
|
|
|
|
|
|
|
cb(null, { options: opts, certs: certs });
|
|
|
|
}
|
2018-05-13 01:22:09 +00:00
|
|
|
```
|
2019-04-03 02:59:11 +00:00
|
|
|
|
|
|
|
If you didn't make the dns challenge globally available in the main greenlock config,
|
|
|
|
you can make it locally available here:
|
|
|
|
|
|
|
|
```js
|
2018-05-13 01:22:09 +00:00
|
|
|
function approveDomains(opts, certs, cb) {
|
|
|
|
...
|
2019-04-03 02:59:11 +00:00
|
|
|
|
|
|
|
if (!opts.challenges) { opts.challenges = {}; }
|
|
|
|
opts.challenges['dns-01'] = leChallengeDns;
|
|
|
|
opts.challenges['http-01'] = ...
|
|
|
|
|
2018-05-13 01:22:09 +00:00
|
|
|
cb(null, { options: opts, certs: certs });
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2016-10-14 19:39:54 +00:00
|
|
|
NOTE: If you request a certificate with 6 domains listed,
|
|
|
|
it will require 6 individual challenges.
|
|
|
|
|
2019-04-03 02:59:11 +00:00
|
|
|
## Exposed Methods
|
2016-10-14 19:39:54 +00:00
|
|
|
|
|
|
|
For ACME Challenge:
|
|
|
|
|
2019-04-03 02:59:11 +00:00
|
|
|
* `set(opts, done)`
|
|
|
|
* `remove(opts, done)`
|
|
|
|
|
|
|
|
The options object has whatever options were set in `approveDomains()` as well as the `challenge`:
|
|
|
|
|
|
|
|
```js
|
|
|
|
{ challenge: {
|
|
|
|
identifier: { type: 'dns', value: 'example.com'
|
|
|
|
, wildcard: true
|
|
|
|
, altname: '*.example.com'
|
|
|
|
, type: 'dns-01'
|
|
|
|
, token: 'xxxxxx'
|
|
|
|
, keyAuthorization: 'xxxxxx.abc123'
|
|
|
|
, dnsHost: '_acme-challenge.example.com'
|
|
|
|
, dnsAuthorization: 'abc123'
|
|
|
|
, expires: '1970-01-01T00:00:00Z'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
2016-10-14 19:39:54 +00:00
|
|
|
|
2019-04-03 02:59:11 +00:00
|
|
|
Note: There's no `get()` because it's the DNS server, not the Greenlock server, that answers the requests.
|
|
|
|
(though I suppose you could implement it if you happen to run your DNS and webserver together... kinda weird though)
|
2016-10-14 19:39:54 +00:00
|
|
|
|
2018-05-13 01:22:09 +00:00
|
|
|
For greenlock.js internals:
|
2016-10-14 19:39:54 +00:00
|
|
|
|
2019-04-03 02:59:11 +00:00
|
|
|
* `options` stores the internal defaults merged with the user-supplied options
|