-
Notifications
You must be signed in to change notification settings - Fork 0
Add certificate storage #8
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
This is code to store keys and certificates on disk. The general way I expect this to be used is outlined in the test: A user generates a key, goes off to a CA for a cert, and stores it as the "next" certificate. Once it is verified to be "good" for whatever definition that means to the caller, they can copy it to the current key. The goal here is to abstract the disk format away from the user, but it uses PEM for both PKCS8 keys and certificates to make it easy to use the files in an external program if required (eg, openssl x509 -text ...)
I thought about doing this but realized it wasn't really needed. Loading checks that they match, so there's no need to eagerly remove certs.
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.
Pull Request Overview
This PR introduces a certificate storage system that manages TLS certificates and private keys on disk using a structured directory layout with "current" and "next" versions for safe certificate rotation.
Key changes:
- Implements a certificate lifecycle management system with "next" staging and "current" production versions
- Provides key generation for P256 ECDSA and RSA 2048-bit keys stored in PKCS8 PEM format
- Includes comprehensive test coverage demonstrating the full certificate rotation workflow
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| storage/storage.go | Core implementation of certificate storage with key generation, certificate staging, and rotation functionality |
| storage/storage_test.go | Test suite validating the complete certificate lifecycle including key generation, storage, and rotation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Using a crypto.Signer makes the tests a bit cleaner, and is what is actually needed to use the key.
This uses constants for next/current, making API call sites more readable. TakeNext now returns the now-current values, which also adds an extra level of protection that the next key and certificate match
This is code to store keys and certificates on disk.
The general way I expect this to be used is outlined in the test:
A user generates a key, goes off to a CA for a cert, and stores it as the "next" certificate. Once it is verified to be "good" for whatever definition that means to the caller, they can copy it to the current key.
The goal here is to abstract the disk format away from the user, but it uses PEM for both PKCS8 keys and certificates to make it easy to use the files in an external program if required (eg, openssl x509 -text ...)