Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add support for UTF8 in x509 subject #397

Closed
Cojad opened this issue May 11, 2016 · 13 comments · May be fixed by #731
Closed

Please add support for UTF8 in x509 subject #397

Cojad opened this issue May 11, 2016 · 13 comments · May be fixed by #731

Comments

@Cojad
Copy link

Cojad commented May 11, 2016

https://github.com/digitalbazaar/forge/blob/master/js/x509.js#L1959

I found the code is default with encoding with PRINTABLESTRING.
Which user have no option to modify the default encoding to utf8 or I missed?
node-forge would produce illegal cert when subject contains UTF8 characters.
I have modify this line to UTF8 in order to produce my certs in correct encoding. I'm not familiar for node.js programing and it took me almost a day to find here to get my job done. But I hope there will be option for change default so one doesn't need to modify the code in node-forge.

@Cojad
Copy link
Author

Cojad commented May 11, 2016

I apologized. There is indeed a way to set utf8 for subjects.

var attr = [
        {name: 'countryName', value: 'TW' valueTagClass: 12},
        {name: 'organizationName', value: 'ass.tw', valueTagClass: 12},
        {shortName: 'ST', value: 'Chinese 大安區', valueTagClass: 12},
        {shortName: 'CN', value: 'Chinese 中文', valueTagClass: 12},
        {shortName: 'OU', value: 'Chinese 中文部門', valueTagClass: 12},
        {shortName: 'CN', value: 'Chinese 中文', valueTagClass: 12}
];

The key is set "valueTagClass" with a value 12 which indicate UTF8. Then you can put UTF8 character in value and produce well formed certs.

@Cojad
Copy link
Author

Cojad commented May 11, 2016

However this didn't fix all the problem. I soon realized that node-forge didn't decode x509 pem correctly with utf8 subject. So I fix it be add a few line in my fork. I'm afraid that my commit doesn't meet the contribute guide. So I din't create a poll from my commit. But feel free to take it.

Cojad@0f6d5d3

@M-OC
Copy link

M-OC commented Jun 24, 2016

+1

@genaromadrid
Copy link

Great @Cojad, your change also fixes UTF8 characters in the issuer... this was exactly what i has looking for

@Cojad
Copy link
Author

Cojad commented Aug 5, 2016

I'm glad that someone find my patch useful. :)

@corelgott
Copy link

+1
I ran into the same problem. We are located in Germany an have an "Umlaut" (äöü) in our cityname. When I tried to sign a csr with a ca that contained an "ü" within the localityName, none of the resulting certs were considered valid.

@Djalmar
Copy link

Djalmar commented Jun 3, 2019

Another solution I have found is to use the valueTagClass field on the subject, when the value is 12(there is a table on asn1.js file) you should decode to fix the problems.

@GitStorageOne
Copy link

Still actual, right?

@kamil7x
Copy link

kamil7x commented Oct 10, 2019

@davidlehn @dlongley any chances that patch created by @Cojad will be picked up by you? Or is there any other solution? I still run into decoding problem and I would like not to fork library.

@davidlehn
Copy link
Member

Does someone have the time to make a PR with that patch and add some tests and maybe a README example?

@kamil7x
Copy link

kamil7x commented Nov 28, 2019

@davidlehn I added PR, could you take a look? It's important in my current project and I don't want to fork your repo

@Cojad
Copy link
Author

Cojad commented Dec 17, 2019

3 years later. I think we can close the issue now. Thanks everyone!

@Cojad Cojad closed this as completed Dec 17, 2019
@GitStorageOne
Copy link

GitStorageOne commented Mar 16, 2020

In ASN.1 there is no valueTagClass with value 12.
Seems, valueTagClass field is wrongly used in general.
12 is value from Type enum and represent UTF8.

// seems, should be something like that
// but it won't work in current version
{ name: 'organizationName', value: 'ass.tw', valueType: asn1.Type.UTF8 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants