9

This was originally posted to the nodejs Github issues page, but it appears that it is an issue with Ubuntu 22.04, so I'm re-posting it here hoping to get further advice. The original thread on Github is here: https://github.com/nodejs/node/issues/43132.

Whenever trying to sign data using nodejs's crypto module, I get an error that OpenSSL cannot load a shared library. If I set the OPENSSL_CONF variable to /dev/null before starting node then I am able to sign data without an issue. This indicates that the problem is likely to be in the /etc/ssl/openssl.cnf config file; however, I'm at a loss on how to track it down further. What can I do to determine what part of the config is failing? If there is a missing/broken engine, how can I provide a working copy?

Steps to Reproduce

I am running Ubuntu 22.04 upgraded from a prior version (21.10 probably but I'm not certain). I originally ran into this issue while using a verison of node installed using nvm, but I can also reproduce it using the nodejs package installed by apt.

Start node and then run this code (NOTE: this key was generated for this example):

var crypto = require('crypto')
var sign = crypto.createSign('RSA-SHA256')
sign.update("TEST INPUT")
sign.sign(`-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDHCN7vsxauuh4M
+VCqxdMwYMV2zLTcCGOIYYRMuCd6Rt3TNKpLmjxmXx3QPvv1QNjDeokFGlnpcxOG
DPs7abkULC12Qdk1wld8apo0qU5xDXDT/beLzc52ykOOySkz0+WxI4sNMqUnLcQq
4FMMTM2CCk4W9z/hZitjqlUyYxLWqgn/Vtp6C1qMD2gFOU3WAFe9jQNvDHJ7H6+5
2nWwFzkaswxHy++6PvzsLtop6/D+cqdKpaiXLzUJvHJbLX4ZLxdMdGq0y7hwhvA8
o2vLf+5cqeoQyobcdczUNC+GjKo9gaMw3j2RSxkfkJT1Mgs0AtBopFrIKLr1Medu
CObjb2vPAgMBAAECggEARrbvokFCQ1UL/TcNQodjp9ISBknnzi9K0bc37pwVJpwM
DxCsmozTfdm4eXcPRM1D1nvwN7hrjoZcvulYz3yaDcE+a8AsgK2qMKGdZS1sGb2Z
QzBnKIw4GTt2skHlWi0kdAG5UziVtexMQKGP0BRvhY7MvNsevqHys4femjbaCBsk
Nv+RoAT1Q/xOAXAy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You get the following error:

Uncaught:
Error: error:25066067:DSO support routines:dlfcn_load:could not load the shared library
    at Sign.sign (internal/crypto/sig.js:103:29) {
  opensslErrorStack: [
    'error:0E076071:configuration file routines:module_run:unknown module name',
    'error:0E07506E:configuration file routines:module_load_dso:error loading dso',
    'error:25070067:DSO support routines:DSO_load:could not load the shared library'
  ],
  library: 'DSO support routines',
  function: 'dlfcn_load',
  reason: 'could not load the shared library',
  code: 'ERR_OSSL_DSO_COULD_NOT_LOAD_THE_SHARED_LIBRARY'
}

Signing data outside of nodejs works just fine (junk.pem contains the same key as above):

$ openssl dgst -sha256 -sign junk.pem junk.pem  | openssl base64
L5ujucYKKzi+ajZi4vVkJNIpoznMLbzZOdgYtS9Y6qrwBlbt9VTpNpzUM3IeWtDe
2gDk563T3qL+1TeLwcbUHiCWeUrCBUdsQofnrAf5pJq9PW4zaWEHjre3g9Gcnqu6
jaWX7K/g1s9RRM0Kif10a3gAzV6Ij3Bw/NsXMouupBd8hUZrqaxwXtcv3pKAtKIS
aIXP34FXtB5qdsAC9kDNH0Sk9hBlhs33eCxhBIOP4xq4IpLWct0aGGDYD8OB1LTC
6JybDir2QqlZ/qmNuesaI7EmW1Pi90MGeTdSG/9nhBTCE0Q0JttNxOfWkSusJADE
N/rBdOR3Fp0PS6FB7hWNzQ==

2 Answers 2

13

The workaround provided by Zoho works for me:

Hence, we suggest you to comment out the lines providers = provider_sect in the file /etc/ssl/openssl.cnf and restart application once.

That is, find the openssl_init section and change it to:

[openssl_init]
#providers = provider_sect

OpenSSL states that if no provider is explicitly configured, the default is loaded, so removing the explicit provider (apparently part of fipsinstall) should be safe.

1
  • This fixed my problem when generating jwt tokens via the npmjs.com/package/mock-jwks library in node, using Pop OS 22.04 (Ubuntu under the hood)
    – icc97
    Jun 22, 2022 at 13:48
1

This issue has been resolved in latest nodejs versions. I encountered this issue with node v16.15.0 after upgrading to Ubuntu 22.04. Issue resolved after upgrading node to v16.16.0

Related release notes: https://nodejs.org/en/blog/vulnerability/july-2022-security-releases/#dll-hijacking-on-windows-high-cve-2022-32223

Github discussion: https://github.com/nodejs/node/discussions/43184

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .