Saturday, April 20, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 5937  / 3 Years ago, mon, september 27, 2021, 12:57:16

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+a8AsgK2q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Nu7erzzWVS31vGWXUeUiMMO9/Q4SVIBPN1c/VSkjgZcn/Hft3C1
tSy7RFfrQHILNt5U3N60XA==
-----END PRIVATE KEY-----`)

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==

More From » nodejs

 Answers
0

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


[#486] Tuesday, September 28, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
teromato

Total Points: 139
Total Questions: 102
Total Answers: 100

Location: Liechtenstein
Member since Mon, May 15, 2023
1 Year ago
teromato questions
;