CSR: Bad UTF-8 parsing from PEM even when using `forge.asn1.Type.UTF8`
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- cryptography
Línea de trabajo
Start at forge.pki.certificationRequestFromPem and trace how the CSR subject value is decoded after ASN.1 parsing, comparing it with forge.util.decodeUtf8 and the UTF8 valueTagClass path. Reproduce the supplied Sišek round trip and verify that certificationRequestFromPem returns the original string while prettyPrint remains correct.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
When creating a CSR with forge 1.3.1 that has a CN with special characters (Sišek), parsing it from PEM messes up the String (SiÅ¡ek) even when valueTagClass: forge.asn1.Type.UTF8 is set.
Sišek expressed as bytes is [83, 105, 197, 161, 101, 107], the problem here is, that each byte is individually interpreted as a UTF-8 codepoint instead of correctly interpreting [197, 161] as a single codepoint.
Converting from Uint8Array to String correctly can be done with new TextDecoder("utf-8").decode(new Uint8Array([83, 105, 197, 161, 101, 107])).
Reading the generated PEM file with OpenSSL produces the correct result.
var keypair = await forge.pki.rsa.generateKeyPair({ bits: 512 });
var csr = forge.pki.createCertificationRequest();
csr.setSubject([{ name: "emailAddress", value: "[email protected]", valueTagClass: forge.asn1.Type.UTF8 }, { name: "commonName", value: "Sišek", valueTagClass: forge.asn1.Type.UTF8 }]);
csr.setAttributes([{ name: "extensionRequest", extensions: [{ name: "subjectAltName", altNames: [{ type: 1, value: "[email protected]" }] }] }]);
csr.publicKey = keypair.publicKey;
csr.sign(keypair.privateKey, forge.md.sha256.create());
console.log(csr.subject.attributes.find((attr) => attr.name == "commonName").value);
// outputs Sišek, as expected
var pem = forge.pki.certificationRequestToPem(csr);
var csrFromPem = forge.pki.certificationRequestFromPem(pem);
console.log(csrFromPem.subject.attributes.find((attr) => attr.name == "commonName").value);
// outputs SiÅ¡ek instead of the expected Sišek
Funnily enough, when using forge.asn1.prettyPrint(forge.pki.certificationRequestToAsn1(csrFromPem)), the String value is displayed correctly (this is also true if the argument is csr). This is achieved by running the value through forge.util.decodeUtf8(value) before displaying it.
- Lenguaje dominante
- JavaScript
- Estrellas
- 5.4k
- Forks
- 875
- Merge medio
- 3 min
- PR fusionados (30 d)
- 6
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de digitalbazaar/forge
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
digitalbazaar/forge#1170 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
digitalbazaar/forge#1147 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
digitalbazaar/forge#1146 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 58/100
digitalbazaar/forge#1145 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 48/100
digitalbazaar/forge#1144 ·
Los mantenedores suelen responder en 1 día
Todos los issues de digitalbazaar/forge
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ImranR98/apps.obtainium.imranr.dev#2000 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
routing: the tray panel's stage stands still with motion reduced while a request is in flightAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
microsoft/monaco-editor#5577 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
obsidianmd/obsidian-help#1169 ·
Los mantenedores suelen responder en 2 días
-
[docs] RELEASE.md: wrong branch name, no check that the prepare PR merged with the right subject, manual publish stepPosiblemente ocupada @albertteoh la tomó hoy. Abiertodocumentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
jaegertracing/jaeger-ui#4739 ·
Los mantenedores suelen responder en 1 día