Repository navigation
Enforce validity of PRINTABLE STRING in names - #12812
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR aims to enforce the validity of PRINTABLE STRING values in X.509 name entries by updating the underlying attribute representation and introducing explicit handling for PrintableString.
- Refactored attribute value handling in name encoding/decoding to use a new AttributeValue enum with a dedicated PrintableString variant.
- Updated dependency references in Cargo.toml to use a git version of the asn1 crate.
- Adjusted the error handling and tag extraction logic for string types in both x509 and cryptography-x509 modules.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/rust/src/x509/common.rs | Updated encode/decode functions to support PrintableString and refined attribute encoding. |
| src/rust/cryptography-x509/src/common.rs | Introduced AttributeValue enum and adjusted tag handling for improved type safety. |
| Cargo.toml | Changed the asn1 dependency to a git source, reflecting the latest version updates. |
Comments suppressed due to low confidence (3)
src/rust/src/x509/common.rs:80
- [nitpick] Consider replacing the informal panic message with a more descriptive error message to aid debugging if this unexpected branch is ever reached.
).expect("I don't think this can ever fail?")
src/rust/src/x509/common.rs:91
- [nitpick] Consider using a more informative error message instead of the informal text to improve clarity in case of failure.
).expect("I don't think this can ever fail?")
src/rust/src/x509/common.rs:239
- [nitpick] Ensure that tests cover the PrintableString branch to verify that the value conforms to expected character set and encoding rules.
AttributeValue::PrintableString(printable_string) => {
alex
force-pushed
the
printable-string-name
branch
from
April 27, 2025 20:23
4449158 to
c1a78f9
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enforces that names only contain valid PRINTABLE STRING characters by adding a new test case and updating the attribute handling in the Rust code.
- Adds a new unit test to ensure that CRL issuers using invalid printable strings raise a ValueError.
- Refactors the encoding and parsing of name attributes to use a richer AttributeValue enum and support new ASN.1 types.
- Updates the asn1 dependency in Cargo.toml to use the latest git version.
Reviewed Changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/x509/test_x509.py | Added a unit test for invalid printable strings in CRL names. |
| src/rust/src/x509/common.rs | Refactored attribute encoding and parsing to support multiple string types. |
| src/rust/cryptography-x509/src/common.rs | Updated type definitions with the new AttributeValue enum and improved tag resolution. |
| Cargo.toml | Replaced the published asn1 dependency with the git version. |
Files not reviewed (2)
- CHANGELOG.rst: Language not supported
- docs/development/test-vectors.rst: Language not supported
Comments suppressed due to low confidence (2)
Cargo.toml:23
- Consider removing the commented out asn1 dependency line to improve clarity in the dependency section.
# asn1 = { version = "0.21.0", default-features = false }
src/rust/src/x509/common.rs:80
- [nitpick] Replace the vague panic message with a more descriptive error message that explains the circumstances under which this failure might occur.
.expect("I don't think this can ever fail?")
alex
force-pushed
the
printable-string-name
branch
2 times, most recently
from
April 28, 2025 01:05
18fb4a2 to
de85363
Compare
alex
force-pushed
the
printable-string-name
branch
from
May 2, 2025 19:36
de85363 to
1332799
Compare
alex
marked this pull request as ready for review
May 2, 2025 19:37
reaperhulk
approved these changes
May 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.