Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

377
Vistas
How to verify JWT token with ES384 algorithm with Nodejs tools signed with JwtSecurityTokenHandler using CNG keys

I'm trying to verify JWT token with Node.js tools signed with JwtSecurityTokenHandler using CNG generated keys

I tried many Nood.js tools e.g. jsonwebtoken

jwt.verify(token, publickey,{ algorithms: ['ES384'], ...

But get wrong tag errors every time

["error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error"],"library":"asn1 encoding routines","function":"asn1_check_tlen","reason":"wrong tag","code":"ERR_OSSL_ASN1_WRONG_TAG"

The public and private keys generated with CNG

 var key = CngKey.Create(CngAlgorithm.ECDsaP384, "keyName",
                new CngKeyCreationParameters
                {
                    KeyCreationOptions = CngKeyCreationOptions.OverwriteExistingKey,
                    KeyUsage = CngKeyUsages.AllUsages,
                    ExportPolicy = CngExportPolicies.AllowPlaintextExport,
                });

            txtPrivateKey = Convert.ToBase64String(key.Export(CngKeyBlobFormat.EccPrivateBlob));
            txtPublicKey = Convert.ToBase64String(key.Export(CngKeyBlobFormat.EccPublicBlob));

I tried with converting the keys, but still getting the same exception. How can I generate a valid public key for Node.js tools using CNG and ES384 algorithm?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

It seems I found the solution:

  1. export private key in pkcs8 format

Convert.ToBase64String(key.Export(CngKeyBlobFormat.Pkcs8PrivateBlob));

  1. save in pem and add BEGIN/END PRIVATE KEY
  2. generate public key with openssl

openssl ec -in pkcs8.pem -pubout -out pkcs8genpubkey.pem

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda