-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add SubjectPublicKeyInfo methods for cert::Cert #253
Conversation
Also, I refrained from pulling in the
They do pass, though 🙂 LMK if you'd like me to add them in. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #253 +/- ##
==========================================
+ Coverage 97.21% 97.27% +0.05%
==========================================
Files 19 19
Lines 4100 4190 +90
==========================================
+ Hits 3986 4076 +90
Misses 114 114 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good 👍
Some of the CI failures are to be expected (e.g. because of the cargo patch). Some are true positives and I've tried to flag a few changes that should fix them.
BTW—I ported the missing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, almost there 🌠
Side-note: is there a |
Lemme also add a quick assertion for |
@lvkv 😆 Unfortunately there isn't anything quite that nice, however you should be able to enable GitHub actions on your fork of the repo. My workflow is to spin a branch off of the one I'm working on, push that to my fork without opening a PR, watch that branch's CI for failures (the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks great :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
Could we reorder / squash some of these commits? I think ideally we could have three commits without compromising on clarity:
- bump the pki-types version first, and drop the earlier hunks that add/remove the temporary patch. That commit should just be Cargo.toml and Cargo.lock.
- "Add der::asn1_wrap function lifted from rustls::x509" plus the associated tests
- "Add public and crate-private SPKI methods on cert::Cert" plus the associated tests
I'd probably prefer to squash all of it? Doesn't make all that much sense to import |
@ctz, I've tidied up these commits—LMK if you'd like any other changes! |
Fair point, but I think the test should be "will this get in the way of git bisect in the future", and warnings won't do that. I think trying to ensure that
I think I prefer this as a separate commit, to isolate the automated changes to Cargo.lock from commits that contain actual human work (in extremis, that means such commits can be just dropped and recreated rather than trying to solve conflicts in a machine-writable-only file). |
I think I disagree, for two reasons:
So one solution for this is that we have a (cc @cpu to review this discussion when you have time.) |
I think if someone were to break up commits this way it would be important for the "why is this being added" context to be present in the commit message.
I find this argument more compelling: I do appreciate refactoring/changes to existing code being done in small increments as opposed to a big all-in-one rewrite, but what you're saying about the advantage of that strategy being reduced for new additions resonates with me. So perhaps we should consider a policy that differs in its commit granularity recommendation based on whether it's largely new code or largely changes to existing code?
That sounds like a good compromise for this situation. If there's consensus on the above we should try to capture some recommendations into the |
Using types from rustls/pki-types#47, this PR adds the following methods for a
cert::Cert
'sSubjectPublicKeyInfo
:pub fn subject_public_key_info(&self) -> SubjectPublicKeyInfo
pub(crate) fn subject_public_key_info_contents(&self) -> &[u8]
As
cert::Cert
's internal representation of aSubjectPublicKeyInfo
(Cert::spki
) lacks the ASN.1 SEQUENCE bytes to make it a proper RFC 5280SubjectPublicKeyInfo
, we need to sneakily add them back when someone callssubject_public_key_info(&self)
. I accomplished this with the addition ofder::asn1_wrap
which I mercilessly lifted from rustls::x509::asn1_wrap. Not completely mercilessly, though—I did make a few improvements to the signature, use of constants, and comments.The motivation behind this is to make it possible to verify consistency for public and private keys (rustls/rustls#1918) —which can be accomplished by comparing SPKI values.