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

Support for UTF-8 chars in subject #731

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kamil7x
Copy link

@kamil7x kamil7x commented Nov 5, 2019

Fixes #397
Based on #397 (comment)

@LuanMaik
Copy link

LuanMaik commented Feb 4, 2021

Why not merge?

@davidlehn
Copy link
Member

@LuanMaik This fell off the radar. It's a challenge to determine if this is the correct fix. Ideally this would refer to the proper part of a spec that defines the behavior, and there would be some tests added. Data in the wild may or may not follow those specs, so that adds more complexity.

Does anyone have time to add test cases for this?

@LuanMaik
Copy link

LuanMaik commented Feb 4, 2021

This is a relevant case to be observed
vbuch/node-signpdf#111

@bopos
Copy link

bopos commented Feb 5, 2021

Hello,

I did a test with two V3 certifcates in the context of pdf signature

  • first one with special chars CN = AC Representación
  • second one with CN = AC Representacion (without special chars)

Without the fix the first one fail
The code called in node-signpdf is https://github.com/vbuch/node-signpdf/blob/develop/src/signpdf.js#L80

    const forgeCert = _nodeForge.default.util.createBuffer(p12Buffer.toString('binary'));
    const p12Asn1 = _nodeForge.default.asn1.fromDer(forgeCert);
    const p12 = _nodeForge.default.pkcs12.pkcs12FromAsn1(p12Asn1, options.asn1StrictParsing, options.passphrase);

For me this PR fix my problem

bopos added a commit to Sage-ERP-X3/forge that referenced this pull request Feb 26, 2021
@SrZorro
Copy link

SrZorro commented May 6, 2021

Hi @davidlehn, could this PR be merged? Or its missing something? The related issue #397 its marked as resolved, but the PR its not merged, there is something we can do to merge it?

At my company we are having the same problem as vbuch/node-signpdf#111 and we ended here, for now we are working with a local fork, but we would like to know if we can do anything to help moving this forward, thanks.

@LuanMaik
Copy link

LuanMaik commented May 7, 2021

What do you think to change this:

if(obj.valueTagClass === asn1.Type.UTF8) {
     obj.value = forge.util.decodeUtf8(obj.value);
} 

to this:

if(obj.valueTagClass === asn1.Type.UTF8) {
   try {
       obj.value = forge.util.decodeUtf8(obj.value);
   } catch(e) { 
      /* This exception means obj.value is utf-8 */ 
   }
} 

to avoid unhandled exceptions, when the obj.value is utf-8 already.

Check: https://stackoverflow.com/questions/36314943/check-if-javascript-string-is-valid-utf-8

@Arturokin
Copy link

I need this fix, why not merge?

@LuanMaik
Copy link

@Arturokin It's necessary to add test cases for this to determine if this is the correct fix.

@kamil7x
Copy link
Author

kamil7x commented Jan 14, 2022

I am not using forge anymore. Maybe someone could jump in and fix this?

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

Successfully merging this pull request may close these issues.

Please add support for UTF8 in x509 subject
6 participants