Skip to content

encoding/asn1: UTF8String being unmarshalled as PrintableString and failing #8541

@tommie

Description

@tommie
> What does 'go version' print?

go version go1.3 linux/amd64

> What steps reproduce the problem?

Attempt to unmarshal a string with non-PrintableString characters in a field with a
context-specific tag and no EXPLICIT: http://play.golang.org/p/5bGjMTiq93

> What happened?

The Broken case returns an error.

> What should have happened instead?

Both cases should work. Most unexpected, note that the "utf8" parameter has no
effect when "tag:1" is present. Adding "explicit" makes Broken work.

Looking at the marshalling output, the Works does properly produce a UTF8String.

I think the problem is that the switch in
https://code.google.com/p/go/source/browse/src/pkg/encoding/asn1/asn1.go?name=go1.3.1#798
is seeing tagPrintableString because
https://code.google.com/p/go/source/browse/src/pkg/encoding/asn1/asn1.go?name=go1.3.1#643
doesn't match in the case of non-universal tags. I see no reference to param.stringType
in the unmarshaller, which is an indication this code does not handle the (non-explicit)
context-specific tags case.

I propose the following patch, falling back to using param.stringType if the on-wire tag
doesn't provide a clue.

Attachments:

  1. asn1printablestring.diff (1451 bytes)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions