-
-
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
x509 AnotherName not encoded correctly #231
Comments
Interesting... That does feel like a bug (or just a limitation in how Lines 527 to 528 in 8a4c621
In other words class AnotherName(Sequence):
_fields = [
('type_id', ObjectIdentifier),
('value', Any, {'explicit': 0}),
]
_oid_pair = ('type_id', 'value')
_oid_specs = {} And you can then even add some mappings to AnotherName._oid_specs['1.3.6.1.4.1.311.20.2.3'] = UTF8String I unfortunately don't have time to test this right now, but it's worth a try. If it works, it's definitely worth doing a PR IMO. In the meantime, you can (reasonably safely) monkeypatch this kind of thing into |
hey Matthias, thanks, this does work pretty well for my problem, your proposed additions work and it can construct the asn1 properly. However it does not fix the reverse parsing from asn1 back to python. Not sure if that's a separate bug or has the same root cause. |
@dirkjanm Looking at the ASN.1 at https://datatracker.ietf.org/doc/html/rfc5280#page-128, it does say that the ANY tag is defined by the type-id. It appears the definition of _oid_pair = ('type_id', 'value')
_oid_specs = {} as suggested by @MatthiasValvekens. My guess is that I hadn't run into such a tag yet, so it hasn't been implemented. That said, you did seem to identify a bug in the parsing. |
Hey, I'm having some issues with creating a cert request with a subject alt name for Microsoft certificates. It comes down to the asn1 encoding of the AnotherName structure, which either is broken or that I simply don't understand how to construct.
I have the following sample code:
This generates the following ASN.1:
However, any Microsoft code can't parse this, because it expects a structure like this:
I'm not an expert on asn1 but it seems something goes wrong with the explicit tagging of the element. In fact, when I try to debug this, the library throws an error:
Curiously enough, when I change the structure of the object in x509.py here:
asn1crypto/asn1crypto/x509.py
Line 1167 in 8a4c621
To the following:
(so instead of
Any
specify aUTF8String
explicitly)Then it encodes without issue, and the bytes are as expected:
With both the original and changed version of the library, the reverse parsing breaks:
Thanks for your work on this, hope this helps track down the issue!
The text was updated successfully, but these errors were encountered: