Closed balnenikhil closed 10 months ago
jwt.sign(<payload>, <utf8 encoded SM2 private key>, { algorithm: 'ES256' }) fails with "error":{"code":"ERR_OSSL_INVALID_DIGEST","library":"Provider routines","reason":"invalid digest"} when using node 18.17.0.
jwt.sign(<payload>, <utf8 encoded SM2 private key>, { algorithm: 'ES256' })
"error":{"code":"ERR_OSSL_INVALID_DIGEST","library":"Provider routines","reason":"invalid digest"}
The above command works fine with node version 16 but fails with node versions 18 and 20.
There is no registered JWS algorithm for SM2 keys^iana and ES256 requires the use of an EC key using the P-256 curve. Furthermore Node.js does not fully support SM2 keys.^node
Bottom line use of SM2 keys with JOSE is unsupported and out of scope.
Description
jwt.sign(<payload>, <utf8 encoded SM2 private key>, { algorithm: 'ES256' })
fails with"error":{"code":"ERR_OSSL_INVALID_DIGEST","library":"Provider routines","reason":"invalid digest"}
when using node 18.17.0.The above command works fine with node version 16 but fails with node versions 18 and 20.
Environment