Skip to content

Add toDerBytes to SSLPrivateKey #540

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

Merged
merged 5 commits into from
Jun 16, 2025
Merged

Add toDerBytes to SSLPrivateKey #540

merged 5 commits into from
Jun 16, 2025

Conversation

gjcairo
Copy link
Contributor

@gjcairo gjcairo commented Jun 11, 2025

This PR adds new API (SSLPrivateKey/toDerBytes()) to get the DER bytes for a private key.
This is only supported for native (EVP) keys; if using a custom key, an empty array of bytes will be returned instead.

@gjcairo gjcairo requested a review from Lukasa June 11, 2025 13:37
@gjcairo gjcairo added the 🆕 semver/minor Adds new public API. label Jun 11, 2025
@gjcairo gjcairo removed the request for review from Lukasa June 11, 2025 13:37
Comment on lines -81 to -83
/// While generally speaking type-erasure has some nasty performance problems, we only need the type-erasure for
/// Hashable conformance, which we don't use in any production code: only the tests use it. To that end, we don't
/// mind too much that we need to do this.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified this comment because I don't think this is true anymore: we are using the type-erased version in NIOSSLPrivateKey

@gjcairo gjcairo requested a review from Lukasa June 13, 2025 14:34
@gjcairo gjcairo requested a review from Lukasa June 13, 2025 15:33
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thanks @gjcairo.

@Lukasa Lukasa merged commit 9173d85 into apple:main Jun 16, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants