]> Cypherpunks repositories - gostls13.git/commitdiff
asn1: allow '*' in PrintableString.
authorAdam Langley <agl@golang.org>
Thu, 10 Jun 2010 00:52:41 +0000 (20:52 -0400)
committerAdam Langley <agl@golang.org>
Thu, 10 Jun 2010 00:52:41 +0000 (20:52 -0400)
Although technically incorrect, we want this in order to parse X.509
certificates where a wildcard hostname ("*.example.com") has been put
into a PrintableString.

Fixes #850.

R=rsc
CC=golang-dev
https://golang.org/cl/1615043

src/pkg/asn1/asn1.go
src/pkg/asn1/marshal_test.go

index fb33afcc28ba51823ac55e76b091ff48294b8934..b8cea93592e218b18119979955720bce1be30204 100644 (file)
@@ -324,7 +324,11 @@ func isPrintable(b byte) bool {
                b == ' ' ||
                b == ':' ||
                b == '=' ||
-               b == '?'
+               b == '?' ||
+               // This is techincally not allowed in a PrintableString.
+               // However, x509 certificates with wildcard strings don't
+               // always use the correct string type so we permit it.
+               b == '*'
 }
 
 // IA5String
index 8050031a7c0db65304b096c8d337fba252283fed..67878f9bb936cabb6bedb51764a7a9d5a1358d32 100644 (file)
@@ -75,6 +75,7 @@ var marshalTests = []marshalTest{
        marshalTest{"test", "130474657374"},
        marshalTest{ia5StringTest{"test"}, "3006160474657374"},
        marshalTest{printableStringTest{"test"}, "3006130474657374"},
+       marshalTest{printableStringTest{"test*"}, "30071305746573742a"},
        marshalTest{rawContentsStruct{nil, 64}, "3003020140"},
        marshalTest{rawContentsStruct{[]byte{0x30, 3, 1, 2, 3}, 64}, "3003010203"},
        marshalTest{RawValue{Tag: 1, Class: 2, IsCompound: false, Bytes: []byte{1, 2, 3}}, "8103010203"},