Store CertificateResource as one unit#3
Conversation
aadbadb to
85ab379
Compare
ErikBooijFR
left a comment
There was a problem hiding this comment.
I love it, I have very high hopes for this change. Some nits mostly
Co-authored-by: ErikBooijFR <erik@framer.com>
Co-authored-by: ErikBooijFR <erik@framer.com>
|
@cursor review |
|
@cursor review |
|
|
||
| // saveCertResource saves the certificate resource to disk. This | ||
| // saveCertResource saves the certificate resource to disk. | ||
| // It switches storage modes between legacy and bundle mode based on the CERTMAGIC_STORAGE_MODE env. |
There was a problem hiding this comment.
Does it make sense to document that everywhere? There's just a good chance this is noise and will be missed on cleanup, and it's not really where you'd search for this documentation -- rather, it appears once on the package, and maybe with a hint on the variable.
(My two cents, YMMV, etc)
There was a problem hiding this comment.
I added them to the other functions. I guess during a cleanup, when we remove StorageModeEnv, the compiler will shout the spots we've missed.
| } | ||
|
|
||
| // saveCertResourceLegacy saves the certificate resource to disk. This | ||
| // includes the certificate file itself, the private key, and the |
There was a problem hiding this comment.
Sentence lost the initial This :)
ankon
left a comment
There was a problem hiding this comment.
I like, a lot!
(I trust the process and that indeed you copy-pasted everything :D)
How certmagic currently stores certs
In certmagic, a certificate consists of three different entities:
These entities are stored and retrieved individually using the
.Load()and.Store()functions, when obtaining or renewing a cert.Problem
The current implementation has two important problems:
certmagic/storage.go
Lines 193 to 205 in 20b57b0
Solution
This change adresses the issue by storing all three entities as a single certificate bundle (.bundle).
As we're operating on a database with live certificates, this change also introduces the concept of a storage mode, that allows for seemless migration from the old to the new storage format:
REVIEW DISCLAIMER
I did not try to be smart about the alternate storage implementation:
Storagehave been duplicated and updated....Legacyfunctions after a full switch.This is pretty much the calling sequence for all functions that do storage things: