From 169cdb6c6a2b6fb9a9c435370d6613ffc2623a1a Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 7 Apr 2019 11:18:49 -0600 Subject: [PATCH] v3.0.0: reference implementation for Greenlock v2.7+ (and v3) --- README.md | 6 ++++-- index.js | 38 +++++++++++++++++++++++++++++++++++++- package-lock.json | 4 ++-- package.json | 4 ++-- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3688033..4442dca 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# le-store-memory +# greenlock-store-memory An in-memory reference implementation of a Certificate and Keypair storage strategy for Greenlock v2.7+ (and v3) @@ -11,7 +11,7 @@ var greenlock = require('greenlock'); // We could have It's used so that we can peek and poke at the store. var cache = {}; var gl = greenlock.create({ - store: require('le-store-memory').create({ cache: cache }) + store: require('greenlock-store-memory').create({ cache: cache }) , approveDomains: approveDomains ... }); @@ -24,6 +24,8 @@ var gl = greenlock.create({ Also, you have the flexibility to get really fancy. _Don't!_ You probably don't need to (unless you already know that you do). +**DON'T BE CLEVER.** Do it the **dumb way first**. + In most cases you're just implementing dumb storage. If all you do is `JSON.stringify()` on `set` (save) and `JSON.parse()` after `check` (get) and just treat it as a blob with an ID, you'll do just fine. You can always optimize later. diff --git a/index.js b/index.js index 5a7043b..91a27fc 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,36 @@ 'use strict'; +// IMPORTANT +// IMPORTANT +// IMPORTANT +// +// Ready? DON'T OVERTHINK IT!!! (Seriously, this is a huge problem) +// +// If you get confused, you're probably smart and thinking too deep. +// +// Want an explanation of how and why? Okay... +// https://coolaj86.com/articles/lets-encrypt-v2-step-by-step/ +// +// But really, you probably don't want to know how and why (because then you'd be implementing your own from scratch) +// +// IMPORTANT +// IMPORTANT +// IMPORTANT +// +// If you want to create a storage strategy quick-and-easy, treat everything as either dumb strings or JSON blobs +// (just as is done here), don't try to do clever optimizations, 5th normal form, etc (you ain't gonna need it), +// but DO use the simple test provided by `greenlock-store-test`. +// +// IMPORTANT +// IMPORTANT +// IMPORTANT +// +// Don't get fancy. Don't overthink it. +// If you want to be fancy and clever, do that after you can pass `greenlock-store-test` the dumb way shown here. +// +// Also: please do contribute clarifying comments. + + module.exports.create = function (opts) { // pass in database url, connection string, filepath, // or whatever it is you need to get your job done well @@ -73,10 +104,15 @@ module.exports.create = function (opts) { - // The certificate keypairs must not be the same as any account keypair + // The certificate keypairs (properly named privkey.pem, though sometimes sutpidly called cert.key) + // https://community.letsencrypt.org/t/what-are-those-pem-files/18402 + // Certificate Keypairs must not be used for Accounts and vice-versamust not be the same as any account keypair + // store.certificates.setKeypair = function (opts) { console.log('certificates.setKeypair:', opts.certificate, opts.subject, opts.keypair); + // The ID is a string that doesn't clash between accounts and certificates. + // That's all you need to know... unless you're doing something special (in which case you're on your own). var id = opts.certificate.kid || opts.certificate.id || opts.subject; var keypair = opts.keypair; diff --git a/package-lock.json b/package-lock.json index 67e9738..aa12a70 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "le-store-memory", - "version": "1.0.1", + "name": "greenlock-store-memory", + "version": "3.0.0", "lockfileVersion": 1 } diff --git a/package.json b/package.json index 5505346..4bfacf4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "le-store-memory", - "version": "1.0.1", + "name": "greenlock-store-memory", + "version": "3.0.0", "description": "An in-memory reference implementation for account, certificate, and keypair storage strategies in Greenlock", "homepage": "https://git.coolaj86.com/coolaj86/le-store-memory.js", "main": "index.js",