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

Read Public Keys from a pemfile #51

Merged
merged 2 commits into from
Aug 3, 2024
Merged

Conversation

holodorum
Copy link
Contributor

@holodorum holodorum commented Jul 31, 2024

This PR supports reading SPKI from a pemfile, which aids the implementation of RFC 7250 (Raw Public Key support) in rustls.

Main changes:

  • We added two functions to read the public keys from pemfiles, public_key() and public_keys(). The public_key() function returns the first SubjectPublicKeyInfoDer it encounters in a pemfile, while public_keys() returns an iterator over all the public keys within a pemfile. Does it ever happen that we have a pemfile with multiple public keys? If not I'll remove this function.
  • To use SubjectPublicKeyInfoDer pki-types is bumped up from version 1.3 to 1.7.

Contributors:

This PR is made in collaboration with @aochagavia.

Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

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

Thanks, this mostly looks good!

src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@cpu cpu left a comment

Choose a reason for hiding this comment

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

Seems reasonable, but I had a couple of questions.

src/pemfile.rs Show resolved Hide resolved
@@ -0,0 +1,14 @@
-----BEGIN PUBLIC KEY-----
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, how was this generated?

Copy link
Contributor Author

@holodorum holodorum Aug 1, 2024

Choose a reason for hiding this comment

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

Using openssl rsa -in private_key.pem -pubout -out public_key.pem

Cargo.toml Show resolved Hide resolved
@djc djc merged commit 38c6f8b into rustls:main Aug 3, 2024
8 checks passed
@djc
Copy link
Member

djc commented Aug 3, 2024

  • Published rustls-pemfile v2.1.3 at registry crates-io
  • [new tag] v/2.1.3 -> v/2.1.3
  • Published release notes

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.

4 participants