ASN.1 error when creating certs containing non ASCII characters

327 views
Skip to first unread message

josvazg

unread,
Jul 1, 2012, 9:08:32 AM7/1/12
to golan...@googlegroups.com
I am trying to generate certificates with content such as:

Locality: Torrejón de Ardoz
Country: España

But the program complains like this:
Failed to create Certificate: 
ASN.1 structure error: PrintableString contains invalid character

And the only way to make it stop it to get rid of all non-Ascii characters within the pkix.Name.
Why does it complain? Does it not support UTF-8?
Is there a way around this?

If there is not I could sanitize users input getting rid of accented vowels and non ascii symbols like Torrejon instead of Torrejón or Espana instead os España, but I only know how to do it properly only for Spanish, and it a like bit undesired to have to use unproper spelling...

josvazg

unread,
Jul 1, 2012, 12:12:13 PM7/1/12
to golan...@googlegroups.com
I think this is an error somewhere.

I just tried to create a Cert with http://simpleauthority.com/ software and it let me put as many non ascii chars as I could come up with to.
So it's either that I doing something wrong or that there is some error in some golang standard packages.

Jose

John Beisley

unread,
Jul 1, 2012, 12:33:33 PM7/1/12
to josvazg, golan...@googlegroups.com
I don't know if it's correct from the ASN.1 standpoint, but the reason
in the code for the error is this:

http://golang.org/src/pkg/encoding/asn1/asn1.go#L286

The string is interpreted byte-by-byte, and it looks like it's only
accepting an ASCII subset.

josvazg

unread,
Jul 1, 2012, 1:49:30 PM7/1/12
to golan...@googlegroups.com
From this RFC:
http://www.ietf.org/rfc/rfc2253.txt

It seems that UTF8 needs to get there escaped, but I thought that the go packages were going to do that for me. After all, go is supposed to be UTF8 all the way.

do I have to do it? Is there a function already to escape UTF8 for asn.1?

Jose

Reply all
Reply to author
Forward
0 new messages