node.jsexpresssslcertificatepfx

Node JS issue with SSL pfx file


when I run my server.js, I have this issue :

node:internal/tls/secure-context:277
      context.loadPKCS12(toBuf(pfx), toBuf(passphrase));
              ^

Error: unsupported
    at configSecureContext (node:internal/tls/secure-context:277:15)
    at Object.createSecureContext (node:_tls_common:117:3)
    at Server.setSecureContext (node:_tls_wrap:1354:27)
    at Server (node:_tls_wrap:1218:8)
    at new Server (node:https:74:3)
    at Object.createServer (node:https:112:10)
    at Object.<anonymous> (/home/user/nodeserver/server.js:21:27)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)

Node.js v18.14.2

I run this command in order to see what's wrong but I can't tell :

openssl pkcs12 -info -in ssl/pfxFile.pfx -noout

Here is the output of the command :

MAC: sha1, Iteration 1024
MAC length: 20, salt length: 20
PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 1024
Certificate bag
Certificate bag
PKCS7 Data
Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 1024

I tried to do the pfx file twice, but same issue each time, I tried without password, I don't know what could block this, I updated Node and now I can't start my server.

Is there a change to Node that alters something with the certificates ?

Thanks for your answers.


Solution

  • Try switching to a lower LTS node version. I've had the same issue today, going from 18.14 LTS to 16.19 LTS solved it. As of today people are still having the same issue.