-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
encoding/asn1: unmarshal of sequence of oid into slice of RawValue #17321
Comments
Hi, Is there any update on this issue as I'm also having a problem where I need to unmarshal into an []asn1.RawValue Thanks |
|
This results in |
@thsnr the struct has un-marshaled SEQUENCE (tag/value):
so what are you expecting to get? |
I expect to get a slice of asn1.RawValues with a single element that has Tag 6 and Bytes 42. Perhaps a Playground with a sequence of two elements gives a better example: Here I would expect to get a slice with two elements, the asn1.RawValue for OBJECT IDENTIFIER {1 2} and the asn1.RawValue for OBJECT IDENTIFIER {3 4}. |
@thsnr I see your point now. From godoc:
So you can easily have a slice of OBJECT IDENTIFIER ( But about Using IMO it's a correct behavior. I leave it to @bradfitz. |
tl;dr: We actually worked around this even before the bug was reported, so I am fine with leaving the current behavior, but it seems to go against the documentation. I will add a little background. While in any sane situation I would just use
So we have to unmarshal a SET OF ANY and one of the possible AttributeValues, Content Type (https://tools.ietf.org/html/rfc5652#section-11.1), was an OBJECT IDENTIFIER, which failed. We worked around this back last year before this issue was reported (also by just unmarshaling into a single
Since we can unmarshal an OBJECT IDENTIFIER into an Also as @m4ns0ur noted, unmarshaling a SEQUENCE OF SEQUENCE into As I said, we have already worked around this situation, so it fine by me to leave the behavior as-is. :) |
@thsnr sounds reasonable, let me look more. |
Change https://golang.org/cl/84095 mentions this issue: |
fixes #1438 `jcmturner/gokrb5` needs to use the `jcmturner/gofork` in order to have some workarounds about some stuff not implemented or not working as expected. For the specific case of github.com/jcmturner/gofork/encoding/asn1 there is no reason right now to keep using `jcmturner/gofork` as the issue golang/go#17321 was solved/closed in Dec 15, 2016 and released in go 1.10 `jcmturner/gokrb5` still uses internally `jcmturner/gofork`, it seems the `gofork` `asn1` part could be removed and use the standar library, but that will need some more work and PRs on the `jcmturner/gokrb5` side.
What version of Go are you using (
go version
)?go version go1.7.1 linux/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
Trying to ASN.1 unmarshal a sequence of object identifiers into a slice of asn1.RawValue:
https://play.golang.org/p/gWzGulJAow
What did you expect to see?
Expected the variable
bad
to contain a single asn1.RawValue element with the raw encoding of the object identifier.What did you see instead?
asn1: structure error: sequence tag mismatch
The text was updated successfully, but these errors were encountered: