-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
ValueError when x500UniqueIdentifier is of type UTF8String #228
Comments
vxgmichel
changed the title
Error when x500UniqueIdentifier is of type UTF8String
ValueError when x500UniqueIdentifier is of type UTF8String
May 10, 2022
If you could provide a PR with a test case that fails using the current implementation, that would make it a bit easier to tweak the implementation to handling such "mis-encoded" certificates. |
vxgmichel
added a commit
to vxgmichel/asn1crypto
that referenced
this issue
Oct 18, 2022
Here you go: #241 :) |
vxgmichel
added a commit
to vxgmichel/asn1crypto
that referenced
this issue
Aug 24, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue is about the attribute
2.5.4.45
, also calleduniqueIdentifier
orx500UniqueIdentifier
:The OID specification for this attribute requires a value of type
BIT STRING
(universal tag 3), but in the wild we might see aUTF8String
type instead (universal tag 12). For instance, it can easily be generated using the followingopenssl
command:openssl req -x509 -newkey rsa:4096 -keyout ca.key -out ca.pem -sha256 -days 365 -subj "/CN=test_ca/x500UniqueIdentifier=test" -nodes
The problem is that
asn1crypto
raises aValueError
when building the corresponding subject, which might cause other apparently unrelated operations to fail. I have listed three such cases in the test module below:It produces the following results:
Note that I have also seen this issue happen here, it happens in case similar to
test_validate_certificate_without_trust_root
when the certificate is not self-signed:https://github.com/wbond/certvalidator/blob/fc82b7975f61fc1b2d1cf7ac77b2e4b2964aedb1/certvalidator/registry.py#L312
In order to fix this issue, I used the following patch:
This patch is trickier than I expected because simply registering
UTF8String.tag
as a bad tag forOctetBitString
wasn't enough: the content ofOctetBitString
also has to be prepended withb"\x00"
in order for the utf-8 string to be interpreted as a bit string.I hope I didn't miss anything important while investigating this issue, and I'll be happy to provide more information if necessary.
The text was updated successfully, but these errors were encountered: