encoding/asn1 currently provides a number of struct field tags to manipulate how fields are parsed/encoded, notably setting the time type, string type, or marking slices or structs as a SET rather than a SEQUENCE.
Unfortunately it is impossible to set these fields on elements of a slice. This makes it impossible to encode certain things like SEQUENCE OF IA5String or parse SEQUENCE OF SET (see #27426 and #18834 for examples).
The only real workaround for this is manually encoding/parsing each element of a slice with MarshalWithParams/UnmarshalWithParams, and then constructing/parsing a SEQUENCE yourself, which is obviously quite prone to errors and overly complex.
Ideally there would be a way to set parameters for each member of the slice. Probably the simplest solution to this problem would be adding a new struct tag, element-param:x or something, which would be passed through to makeField/parseField. For example this would then allow the following struct
type example struct {
A []string `asn1:"element-param:ia5"`
}
encoding/asn1 currently provides a number of struct field tags to manipulate how fields are parsed/encoded, notably setting the time type, string type, or marking slices or structs as a SET rather than a SEQUENCE.
Unfortunately it is impossible to set these fields on elements of a slice. This makes it impossible to encode certain things like
SEQUENCE OF IA5String
or parseSEQUENCE OF SET
(see #27426 and #18834 for examples).The only real workaround for this is manually encoding/parsing each element of a slice with
MarshalWithParams
/UnmarshalWithParams
, and then constructing/parsing a SEQUENCE yourself, which is obviously quite prone to errors and overly complex.Ideally there would be a way to set parameters for each member of the slice. Probably the simplest solution to this problem would be adding a new struct tag,
element-param:x
or something, which would be passed through tomakeField
/parseField
. For example this would then allow the following structto be encoded as a
SEQUENCE OF IA5String
.cc @FiloSottile @katiehockman
The text was updated successfully, but these errors were encountered: