-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Allow to serialize extension values as DER bytes strings #6346
Conversation
We're going to convert X509 encoding to Rust next so I'd prefer to tackle this after we do that conversion. With the rust code we can just call |
62aeeb1
to
5c26542
Compare
e20b057
to
b4fa36a
Compare
@reaperhulk @alex I've reworked this PR to use the Rust code to serialize the extension values (and falls back to Python+OpenSSL for the ones not yet supported by the Rust code). Does the approach look sensible / acceptable? (I've added in the comments what needs to be updated once all extensions are serialized by Rust code.) |
0c56e98
to
91d7e66
Compare
1b0c7b8
to
0f3af97
Compare
I've rebased and added a last test to reach 100% coverage after #6439 was merged. This is now ready for review. |
This PR took advantage of a window where we had exposed public methods for extension encoding. Those are now gone as we completed our x509 conversion. However, we can add methods back, we should just scope them to doing exactly what this method requires. It seems like what you really want is a single rust method I also think the name here should probably be |
0f3af97
to
22cef59
Compare
5d18da0
to
88189ad
Compare
@reaperhulk thanks for the feedback! I've renamed it to The failing CI check seems to be unrelated to this PR (or there is something very strange going on I don't understand...). |
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.
also have a changelog conflict
c9cf6ed
to
e1dc35f
Compare
257172e
to
61cd25b
Compare
Rebased on top of #6571. |
61cd25b
to
c316f93
Compare
c316f93
to
f6163b9
Compare
Rebased after #6571 was merged, and CI is green on the first try 🎉 |
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.
approving even though our serialization for KU needs to properly account for unused bits because this code will improve testing for the fix.
@reaperhulk @alex thanks a lot for reviewing and merging! |
This is another try to implement #5002 (Support for getting ASN.1 value for parsed extensions).
It uses the existing backend function
_create_x509_extension()
to convert a extension created for this extension value to an OpenSSL extension, and then uses the same code as incryptography/src/cryptography/hazmat/backends/openssl/decode_asn1.py
Lines 239 to 242 in 70ccc25
encode_asn1.py
(I checked that the same OID in different mappings are mapped to the same function, in case someone wonders).If the general approach looks good, I can add documentation and tests.