Skip to content

rcgen: stop storing key DER in KeyPair - #453

Merged
djc merged 2 commits into
mainfrom
no-key-pair-der
Sep 21, 2026
Merged

djc merged 2 commits into
mainfrom
no-key-pair-der

Conversation

@djc

@djc djc commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

First semver-incompatible PR on main for 0.15.0.

Preparation for

cc @jgreeer

@djc
djc requested review from cpu and est31 September 11, 2026 11:25
@djc
djc force-pushed the no-key-pair-der branch 2 times, most recently from 2b77217 to 48e6f58 Compare September 11, 2026 13:02
Comment thread rcgen/src/key_pair.rs Resolved
Comment thread rcgen/src/key_pair.rs Resolved
@cpu

cpu commented Sep 21, 2026

Copy link
Copy Markdown
Member

Preparation for #450

Can you say more about the motivation? The diff doesn't seem completely unreasonable, but it's also making a lot of places throw away a return value from the key generation. It feels mildly like the older approach was a little bit more ergonomic and I'm not sure I'm 100% on what we gain by trading some of that away to not have the KeyPair hold the DER.

@djc

djc commented Sep 21, 2026 •

Copy link
Copy Markdown
Member Author

Preparation for #450

Can you say more about the motivation? The diff doesn't seem completely unreasonable, but it's also making a lot of places throw away a return value from the key generation. It feels mildly like the older approach was a little bit more ergonomic and I'm not sure I'm 100% on what we gain by trading some of that away to not have the KeyPair hold the DER.

In my mind the next step here is getting rid of KeyPair completely in favor of only having Box<dyn SigningKey>, which seems like a mostly unnecessary layer at this point (which would need more complexity with crypto providers). In terms of defense in depth, since rcgen does not need the type capable of signing to also contain a more readable/leakable copy of the private key contents we should probably not retain/hold that by default.

Comment thread rcgen/src/lib.rs Resolved
Comment thread rcgen/src/key_pair.rs Resolved
Comment thread rcgen/src/key_pair.rs Resolved
Comment thread rustls-cert-gen/Cargo.toml Resolved
@djc
djc force-pushed the no-key-pair-der branch 2 times, most recently from 371923a to 3b24e6f Compare September 21, 2026 14:49
Comment thread README.md Resolved
@djc
djc enabled auto-merge September 21, 2026 14:56
@djc
djc added this pull request to the merge queue Sep 21, 2026
Merged via the queue into main with commit 534b43c Sep 21, 2026
17 checks passed
@djc
djc deleted the no-key-pair-der branch September 21, 2026 15:34
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

Successfully merging this pull request may close these issues.

3 participants