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

Unreadable codes in Chinese when use win-ca #29

Open
yaphone opened this issue May 31, 2020 · 6 comments
Open

Unreadable codes in Chinese when use win-ca #29

yaphone opened this issue May 31, 2020 · 6 comments
Assignees
Labels

Comments

@yaphone
Copy link

yaphone commented May 31, 2020

Hi,
I use win-ca in my nodejs project to get certificate, and here is my code:

export function getAllCerts() {
  return new Promise(resolve => {
    ca({
      async: true,
      format: ca.der2.txt,
      ondata: roots,
      onend: resolve
    })
  }).then(() => {
    console.log(roots)
    return roots
  })

And it works well in English format, but when the certificate content contains Chinese, I got unreadable codes. I think the reason is the encoding format in win-ca,and I want to know how to resolve this problem.

THX very much!

@yaphone
Copy link
Author

yaphone commented May 31, 2020

node -v 10.14.1
win-ca 3.2.0

@ukoloff
Copy link
Owner

ukoloff commented Jun 1, 2020

Well, certificates with UTF-8 strings is still terra incognita in Russia, we strongly prefer to avoid them, using transliteration to Latin-1. So, such errors are very likely to occur and voila!

I don't even know whose error is this - mine on node-forge`s. Or both ;-)

Could you please attach sample certificate that leads to unreadable text?

So far I believe you can fetch certificates in PEM format and parse them yourself. I'll try to fix but it will take some time...

@ukoloff ukoloff self-assigned this Jun 1, 2020
@ukoloff ukoloff added the bug label Jun 1, 2020
@yaphone
Copy link
Author

yaphone commented Jun 1, 2020

THX for your reply.

I will attach a root certificate whose contents contains Chinese when I back to my office tomrrow~

This is a great project, and very helpful to our project! I have tried to debug win-ca code, but I found it hard to understand,and I still trying...

@yaphone
Copy link
Author

yaphone commented Jun 2, 2020

I found this may not the problem with coding format, I generated a certificate and store it in 'MY' by follow cmd:
makecert -n "CN=陕西税务总局 测试Subject" -b 08/05/2019 -e 08/05/2022 -ss my -r TestIssuer.cer Succeeded
then use it in my node project by win-ca, I got right result:
image

And the unreadable coding certificate is in USB KEY, I can not get the hardware right now, I will try later~

@yaphone
Copy link
Author

yaphone commented Jun 9, 2020

Hi, bro
I think I get the point, it is a bug of node-forge, I have make a PR to node-forge repository, you can check it here

@ukoloff
Copy link
Owner

ukoloff commented Sep 15, 2020

I spent some time playing with UTF-8 certificates and that is what I think now:

  1. Your PR to node-forge should be cancelled. It changes API so it would break a lot of dependent packages
  2. Inside win-ca I manually convert binary strings to UTF-8
  3. It seems to fix problems with all UTF-8 certificates I have got (more than 20, including Chines, Turkish and Hungarian)
  4. I released beta-version of win-ca. Install as npm i win-ca@utf8
  5. Feel free to test and report

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

No branches or pull requests

2 participants