Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Read Public Keys from a pemfile#51

Merged
djc merged 2 commits intorustls:mainfrom
holodorum:read_public_keys
Aug 3, 2024
Merged

Read Public Keys from a pemfile#51
djc merged 2 commits intorustls:mainfrom
holodorum:read_public_keys

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!

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.

@@ -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

@djc djc merged commit 38c6f8b into rustls:main Aug 3, 2024
@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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants