From 4cd1a03d8acb432d0e04f7104906b0750c7ca179 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 16 Apr 2018 01:28:05 +0000 Subject: [PATCH] v2.2.0 --- README.md | 17 ++++++++++++++++- index.js | 50 +++++++++++++++++++++++++++++++++++++++++++++----- package.json | 32 +++++++++++++++++++++++++++----- 3 files changed, 88 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 267558e..9b49e51 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,16 @@ greenlock (node-letsencrypt) ========= +Now supports **Let's Encrypt v2**!! + +| [acme-v2.js](https://git.coolaj86.com/coolaj86/acme-v2.js) | **greenlock** | [greenlock-cli](https://git.coolaj86.com/coolaj86/greenlock-cli.js) | [greenlock-express](https://git.coolaj86.com/coolaj86/greenlock-express.js) | [greenlock-cluster](https://git.coolaj86.com/coolaj86/greenlock-cluster.js) | [greenlock-koa](https://git.coolaj86.com/coolaj86/greenlock-koa.js) | [greenlock-hapi](https://git.coolaj86.com/coolaj86/greenlock-hapi.js) + | Sponsored by [ppl](https://ppl.family) Automatic [Let's Encrypt](https://letsencrypt.org) (ACME) HTTPS / TLS / SSL Certificates for node.js @@ -125,7 +129,18 @@ function leAgree(opts, agreeCb) { } le = LE.create({ - server: LE.stagingServerUrl // or LE.productionServerUrl + version: 'draft-11' // 'draft-11' or 'v01' + // 'draft-11' is for Let's Encrypt v2 otherwise known as ACME draft 11 + // 'v02' is an alias for 'draft-11' + // 'v01' is for the pre-spec Let's Encrypt v1 + // + // staging API + server: 'https://acme-staging-v02.api.letsencrypt.org/directory' + + // + // production API + //server: 'https://acme-v02.api.letsencrypt.org/directory' + , store: leStore // handles saving of config, accounts, and certificates , challenges: { 'http-01': leHttpChallenge // handles /.well-known/acme-challege keys and tokens diff --git a/index.js b/index.js index ad7a3f0..401d4fc 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ var DAY = 24 * 60 * 60 * 1000; //var MIN = 60 * 1000; -var ACME = require('le-acme-core').ACME; +var ACME = require('acme-v2/compat').ACME; var LE = module.exports; LE.LE = LE; @@ -19,12 +19,12 @@ function _log(debug) { } LE.defaults = { - productionServerUrl: ACME.productionServerUrl -, stagingServerUrl: ACME.stagingServerUrl + productionServerUrl: 'https://acme-v02.api.letsencrypt.org/directory' +, stagingServerUrl: 'https://acme-staging-v02.api.letsencrypt.org/directory' , rsaKeySize: ACME.rsaKeySize || 2048 , challengeType: ACME.challengeType || 'http-01' -, challengeTypes: ACME.challengeTypes || [ 'http-01', 'tls-sni-01', 'dns-01' ] +, challengeTypes: ACME.challengeTypes || [ 'http-01', 'dns-01' ] , acmeChallengePrefix: ACME.acmeChallengePrefix }; @@ -53,6 +53,7 @@ LE._undefined = { , rsaKeySize: u , challengeType: u , server: u +, version: u , agreeToTerms: u , _ipc: u , duplicate: u @@ -70,7 +71,6 @@ LE._undefine = function (le) { LE.create = function (le) { var PromiseA = require('bluebird'); - le.acme = le.acme || ACME.create({ debug: le.debug }); le.store = le.store || require('le-store-certbot').create({ debug: le.debug }); le.core = require('./lib/core'); var log = le.log || _log; @@ -81,9 +81,11 @@ LE.create = function (le) { 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'] = require('le-challenge-sni').create({ debug: le.debug }); } + */ if (!le.challenges['dns-01']) { try { le.challenges['dns-01'] = require('le-challenge-ddns').create({ debug: le.debug }); @@ -118,6 +120,42 @@ LE.create = function (le) { le.server = LE.productionServerUrl; } + if (-1 !== [ 'https://acme-v01.api.letsencrypt.org/directory' + , 'https://acme-staging.api.letsencrypt.org/directory' ].indexOf(le.server)) { + ACME = require('le-acme-core').ACME; + console.warn("Let's Encrypt v1 is deprecated. Please update to Let's Encrypt v2 (ACME draft 11)"); + } + else if (-1 !=== [ 'https://acme-v02.api.letsencrypt.org/directory' + , 'https://acme-staging-v02.api.letsencrypt.org/directory' ].indexOf(le.server)) { + if ('v02' !== le.version && 'draft-11' !== le.version) { + ACME = require('le-acme-core').ACME; + if ('v01' !== le.version) { + //console.warn("Please specify version: 'v01' (Let's Encrypt v1) or 'draft-11' (Let's Encrypt v2 / ACME draft 11)"); + console.warn(""); + console.warn(""); + console.warn(""); + console.warn("===================================================================="); + console.warn("== greenlock.js (v2.2.0+) =="); + console.warn("===================================================================="); + console.warn(""); + console.warn("Please specify 'version' option:"); + console.warn(""); + console.warn(" 'v01' for Let's Encrypt v1"); + console.warn(" or"); + console.warn(" 'draft-11' for Let's Encrypt v2 and ACME draft 11"); + console.warn(" ('v02' is an alias of 'draft-11'"); + console.warn(""); + console.warn("===================================================================="); + console.warn("== this will be required from version v2.3 forward =="); + console.warn("===================================================================="); + console.warn(""); + console.warn(""); + console.warn(""); + } + } + } + + le.acme = le.acme || ACME.create({ debug: le.debug }); if (le.acme.create) { le.acme = le.acme.create(le); } @@ -183,6 +221,7 @@ LE.create = function (le) { + " You must define removeChallenge as function (opts, domain, token, cb) { }"); } +/* if (!le._challengeWarn && (!challenger.loopback || 4 !== challenger.loopback.length)) { le._challengeWarn = true; console.warn("le.challenges[" + challengeType + "].loopback should be defined as function (opts, domain, token, cb) { ... } and should prove (by external means) that the ACME server challenge '" + challengeType + "' will succeed"); @@ -191,6 +230,7 @@ LE.create = function (le) { le._challengeWarn = true; console.warn("le.challenges[" + challengeType + "].test should be defined as function (opts, domain, token, keyAuthorization, cb) { ... } and should prove (by external means) that the ACME server challenge '" + challengeType + "' will succeed"); } +*/ }); le.sni = le.sni || null; diff --git a/package.json b/package.json index def8d02..7b219ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "greenlock", - "version": "2.1.17", + "version": "2.2.0", "description": "Let's Encrypt for node.js on npm", "main": "index.js", "scripts": { @@ -11,14 +11,35 @@ "url": "git+https://git.coolaj86.com/coolaj86/greenlock.js.git" }, "keywords": [ - "greenlock", + "acmev2", + "acmev02", + "acme-v2", + "acme-v02", + "acme", + "acme2", + "acme11", + "acme-draft11", + "acme-draft-11", + "draft", + "11", + "free", + "ssl", + "tls", + "https", + "Let's Encrypt", "letsencrypt", + "letsencrypt-v2", + "letsencrypt-v02", + "letsencryptv2", + "letsencryptv02", + "letsencrypt2", + "v2", + "v02", + "greenlock", "letsencrypt.org", "le", - "Let's Encrypt", "lejs", "le.js", - "acme", "node", "nodejs", "node.js", @@ -35,11 +56,12 @@ }, "optionalDependencies": {}, "dependencies": { + "acme-v2": "git+https://git.coolaj86.com/coolaj86/acme-v2.js.git#master", "asn1js": "^1.2.12", "bluebird": "^3.0.6", "certpem": "^1.0.0", "homedir": "^0.6.0", - "le-acme-core": "^2.0.5", + "le-acme-core": "^2.1.2", "le-challenge-fs": "^2.0.2", "le-challenge-sni": "^2.0.0", "le-sni-auto": "^2.1.0",