win-ca
win-ca copied to clipboard
Unreadable codes in Chinese when use win-ca
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!
node -v 10.14.1 win-ca 3.2.0
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...
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...
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:
And the unreadable coding certificate is in USB KEY, I can not get the hardware right now, I will try later~
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
I spent some time playing with UTF-8 certificates and that is what I think now:
- Your PR to node-forge should be cancelled. It changes API so it would break a lot of dependent packages
- Inside
win-ca
I manually convert binary strings to UTF-8 - It seems to fix problems with all UTF-8 certificates I have got (more than 20, including Chines, Turkish and Hungarian)
- I released beta-version of
win-ca
. Install asnpm i win-ca@utf8
- Feel free to test and report