2018-03-15 06:41:00 +00:00
|
|
|
acme-v2.js
|
|
|
|
==========
|
|
|
|
|
2018-03-21 07:35:28 +00:00
|
|
|
| Sponsored by [ppl](https://ppl.family)
|
|
|
|
|
2018-03-15 06:41:00 +00:00
|
|
|
A framework for building letsencrypt clients (and other ACME v2 clients), forked from `le-acme-core.js`.
|
|
|
|
|
2018-03-15 06:43:41 +00:00
|
|
|
Summary of spec that I'm working off of here: https://git.coolaj86.com/coolaj86/greenlock.js/issues/5#issuecomment-8
|
|
|
|
|
2018-03-15 06:41:00 +00:00
|
|
|
In progress
|
|
|
|
|
2018-03-20 07:24:36 +00:00
|
|
|
* Mar 15, 2018 - get directory
|
|
|
|
* Mar 15, 2018 - get nonce
|
|
|
|
* Mar 15, 2018 - generate account keypair
|
|
|
|
* Mar 15, 2018 - create account
|
|
|
|
* Mar 16, 2018 - new order
|
|
|
|
* Mar 16, 2018 - get challenges
|
|
|
|
* Mar 20, 2018 - respond to challenges
|
|
|
|
* Mar 20, 2018 - generate domain keypair
|
|
|
|
* Mar 20, 2018 - finalize order (submit csr)
|
|
|
|
* Mar 20, 2018 - poll for status
|
|
|
|
* Mar 20, 2018 - download certificate
|
|
|
|
* Mar 20, 2018 - SUCCESS - got a test certificate (hard-coded)
|
2018-03-21 07:26:23 +00:00
|
|
|
* Mar 21, 2018 - can now accept values (not hard coded)
|
|
|
|
* Mar 21, 2018 - *mostly* matches le-acme-core.js API
|
2018-04-05 08:28:29 +00:00
|
|
|
* Apr 5, 2018 - completely match api for acme v1 (le-acme-core.js)
|
2018-04-05 08:48:10 +00:00
|
|
|
* Apr 5, 2018 - test wildcard
|
2018-04-05 09:37:41 +00:00
|
|
|
* Apr 5, 2018 - test two subdomains
|
|
|
|
* Apr 5, 2018 - test subdomains and its wildcard
|
2018-03-16 06:59:40 +00:00
|
|
|
|
2018-03-20 07:24:36 +00:00
|
|
|
Todo
|
|
|
|
|
2018-03-21 07:26:23 +00:00
|
|
|
* test http and dns challenges
|
|
|
|
* export http and dns challenge tests
|
|
|
|
* support ECDSA keys
|
|
|
|
|
2018-04-05 07:31:57 +00:00
|
|
|
## Let's Encrypt Directory URLs
|
|
|
|
|
|
|
|
```
|
|
|
|
# Production URL
|
|
|
|
https://acme-v02.api.letsencrypt.org/directory
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
|
|
|
# Staging URL
|
|
|
|
https://acme-staging-v02.api.letsencrypt.org/directory
|
|
|
|
```
|
|
|
|
|
2018-03-21 07:26:23 +00:00
|
|
|
## API
|
|
|
|
|
|
|
|
```
|
2018-04-05 07:31:57 +00:00
|
|
|
var ACME = require('acme-v2').ACME.create({
|
2018-03-21 07:26:23 +00:00
|
|
|
RSA: require('rsa-compat').RSA
|
2018-04-05 07:31:57 +00:00
|
|
|
|
|
|
|
// other overrides
|
|
|
|
, request: require('request')
|
|
|
|
, promisify: require('util').promisify
|
|
|
|
|
|
|
|
// used for constructing user-agent
|
|
|
|
, os: require('os')
|
|
|
|
, process: require('process')
|
|
|
|
|
|
|
|
// used for overriding the default user-agent
|
|
|
|
, userAgent: 'My custom UA String'
|
|
|
|
, getUserAgentString: function (deps) { return 'My custom UA String'; }
|
2018-03-21 07:26:23 +00:00
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
// Accounts
|
2018-04-05 07:31:57 +00:00
|
|
|
ACME.accounts.create(options) // returns Promise<regr> registration data
|
2018-03-21 07:26:23 +00:00
|
|
|
|
|
|
|
{ email: '<email>' // valid email (server checks MX records)
|
|
|
|
, accountKeypair: { // privateKeyPem or privateKeyJwt
|
|
|
|
privateKeyPem: '<ASCII PEM>'
|
|
|
|
}
|
2018-04-05 07:31:57 +00:00
|
|
|
, agreeToTerms: fn (tosUrl) {} // returns Promise with tosUrl
|
2018-03-21 07:26:23 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 07:31:57 +00:00
|
|
|
|
2018-03-21 07:26:23 +00:00
|
|
|
// Registration
|
2018-04-05 07:31:57 +00:00
|
|
|
ACME.certificates.create(options) // returns Promise<pems={ privkey (key), cert, chain (ca) }>
|
2018-03-21 07:26:23 +00:00
|
|
|
|
|
|
|
{ newAuthzUrl: '<url>' // specify acmeUrls.newAuthz
|
|
|
|
, newCertUrl: '<url>' // specify acmeUrls.newCert
|
|
|
|
|
|
|
|
, domainKeypair: {
|
|
|
|
privateKeyPem: '<ASCII PEM>'
|
|
|
|
}
|
|
|
|
, accountKeypair: {
|
|
|
|
privateKeyPem: '<ASCII PEM>'
|
|
|
|
}
|
|
|
|
, domains: [ 'example.com' ]
|
|
|
|
|
2018-04-05 07:31:57 +00:00
|
|
|
, setChallenge: fn (hostname, key, val) // return Promise
|
|
|
|
, removeChallenge: fn (hostname, key) // return Promise
|
2018-03-21 07:26:23 +00:00
|
|
|
}
|
|
|
|
|
2018-04-05 07:31:57 +00:00
|
|
|
|
2018-03-21 07:26:23 +00:00
|
|
|
// Discovery URLs
|
2018-04-05 07:31:57 +00:00
|
|
|
ACME.init(acmeDirectoryUrl) // returns Promise<acmeUrls={keyChange,meta,newAccount,newNonce,newOrder,revokeCert}>
|
2018-03-21 07:26:23 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Helpers & Stuff
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
// Constants
|
|
|
|
ACME.acmeChallengePrefix // /.well-known/acme-challenge/
|
|
|
|
```
|
|
|
|
|