diff -Nru orig/pkg/encoding/asn1/asn1.go new/pkg/encoding/asn1/asn1.go --- orig/pkg/encoding/asn1/asn1.go 2014-08-16 21:32:15.000000000 +0100 +++ new/pkg/encoding/asn1/asn1.go 2014-08-16 21:33:26.000000000 +0100 @@ -643,6 +643,10 @@ switch t.tag { case tagIA5String, tagGeneralString, tagT61String, tagUTF8String: universalTag = t.tag + default: + if params.stringType != 0 { + universalTag = params.stringType + } } } diff -Nru orig/pkg/encoding/asn1/asn1_test.go new/pkg/encoding/asn1/asn1_test.go --- orig/pkg/encoding/asn1/asn1_test.go 2014-08-16 21:32:15.000000000 +0100 +++ new/pkg/encoding/asn1/asn1_test.go 2014-08-16 21:33:26.000000000 +0100 @@ -392,6 +392,10 @@ B int } +type TestContextSpecificTags3 struct { + S string `asn1:"tag:1,utf8"` +} + type TestElementsAfterString struct { S string A, B int @@ -420,6 +424,7 @@ {[]byte{0x04, 0x04, 1, 2, 3, 4}, &RawValue{0, 4, false, []byte{1, 2, 3, 4}, []byte{4, 4, 1, 2, 3, 4}}}, {[]byte{0x30, 0x03, 0x81, 0x01, 0x01}, &TestContextSpecificTags{1}}, {[]byte{0x30, 0x08, 0xa1, 0x03, 0x02, 0x01, 0x01, 0x02, 0x01, 0x02}, &TestContextSpecificTags2{1, 2}}, + {[]byte{0x30, 0x03, 0x81, 0x01, '@'}, &TestContextSpecificTags3{"@"}}, {[]byte{0x01, 0x01, 0x00}, newBool(false)}, {[]byte{0x01, 0x01, 0xff}, newBool(true)}, {[]byte{0x30, 0x0b, 0x13, 0x03, 0x66, 0x6f, 0x6f, 0x02, 0x01, 0x22, 0x02, 0x01, 0x33}, &TestElementsAfterString{"foo", 0x22, 0x33}},