-
Notifications
You must be signed in to change notification settings - Fork 1
Store CertificateResource as one unit #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
aadbadb to
85ab379
Compare
ErikBooijFR
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment @cursor review or bugbot run to trigger another review on this PR
|
@cursor review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment @cursor review or bugbot run to trigger another review on this PR
|
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sentence lost the initial This :)
ankon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: