Skip to content
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

Certificate stored before private key #149

Closed
sam-lord opened this issue Oct 30, 2021 · 1 comment
Closed

Certificate stored before private key #149

sam-lord opened this issue Oct 30, 2021 · 1 comment

Comments

@sam-lord
Copy link
Contributor

What version of the package are you using?

Latest release, 0.15.1

What are you trying to do?

Create a wrapper around the storage (which also implements certmagic.Store) so that I can upload certificates to a CDN whilst storing the certs in a compatible way otherwise.

What steps did you take?

Implemented a new store which just passes all of the function calls to the storage passed in. Added some more logic to Store so that certificates and private keys are uploaded to the CDN.

What did you expect to happen, and what actually happened instead?

Private key to be generated first, as the private key has to exist for the certificate to function. The CDN in use rejects requests to add a certificate if the private key for the certificate is missing.

How do you think this should be fixed?

  • Swap the order that these two files are uploaded (in crypto.go. I can't see any way that this could negatively impact the compatibility.

Please link to any related issues, pull requests, and/or discussion

Bonus: What do you use CertMagic for, and do you find it useful?

So exciting to be using the project in my app. Hopefully will be able to announce something soon!

@mholt
Copy link
Member

mholt commented Oct 30, 2021

The private key is always created before the certificate, it's impossible to do it any other way.

To clarify, you're referring instead to the order in which the assets are saved, though, right, i.e. the order of elements in this slice?

certmagic/crypto.go

Lines 148 to 163 in 1c89882

all := []keyValue{
{
key: StorageKeys.SiteCert(issuerKey, certKey),
value: cert.CertificatePEM,
},
{
key: StorageKeys.SitePrivateKey(issuerKey, certKey),
value: cert.PrivateKeyPEM,
},
{
key: StorageKeys.SiteMeta(issuerKey, certKey),
value: metaBytes,
},
}
return storeTx(cfg.Storage, all)

If so, I guess we can make that change. Shouldn't be a big deal.

@mholt mholt changed the title Certificate created before private key Certificate stored before private key Oct 30, 2021
@mholt mholt closed this as completed in f3d6482 Oct 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants