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

Signing leaf certificates with parsed intermediate #268

Open
pfzetto opened this issue Apr 17, 2024 · 2 comments
Open

Signing leaf certificates with parsed intermediate #268

pfzetto opened this issue Apr 17, 2024 · 2 comments

Comments

@pfzetto
Copy link

pfzetto commented Apr 17, 2024

Hello,
I'm currently building a small PoC using this Library and stumbled upon the following error:

I have generated three Certificates (Root, Intermediate,Leave) and key pairs.
The blockage reveals itself when I try to load the Intermediate Certificate.
From the public documentation I learned that I can load a certificate by deserializing the Certificate using CertificateParams::from_ca_cert_pem and signing it using CertificateParams::self_signed or CertificateParams::signed_by.
In my case self signing the certificate would break the chain and I don't have access to the root private key to sign the intermediary on every restart of the server.
In the Issues I've learned that there was a Certificate::from_pem that should satisfy my case but got it removed.

How can I load an existing CA Certificate without 'resigning' it?

Thanks
Paul

@djc
Copy link
Member

djc commented Apr 18, 2024

In my case self signing the certificate would break the chain and I don't have access to the root private key to sign the intermediary on every restart of the server.

You're right that this area of the library is a little tricky to navigate right now.

I think the workaround for now is that the signature on the intermediate Certificate you use to sign isn't actually used when signing the leaf certificate, so it's actually fine to sign the intermediate with a random KeyPair if the resulting Certificate is actually only used to then sign the leaf certificate -- this intermediate Certificate wouldn't be able to be verified by clients that are actually verifying its signature against your root certificate, but only its params are being used to sign the leaf certificate anyway, and those are legit (since they originated from parsing the actual intermediate).

Does that make sense? We definitely need to improve the API in this area and it's something I've been working on but ran out of time to get done before the 0.13 release.

@djc djc changed the title Deserializing an Intermediate Certificate Signing leaf certificates with parsed intermediate Apr 18, 2024
@pfzetto
Copy link
Author

pfzetto commented Apr 18, 2024

Thanks, the "hack" works. I've only needed to manually modify the pem of the leaf certificate to include the original pem of the intermediary to complete the chain.

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