import admin from 'firebase-admin'

admin.auth().createCustomToken(stringID, {
    id: stringID, 
}) // throws the error below
 Error: error:25066067:DSO support routines:dlfcn_load:could not load the shared library
    at Sign.sign (node:internal/crypto/sig:131:29)
    at ServiceAccountSigner.sign (/node_modules/firebase-admin/lib/utils/crypto-signer.js:65:37)
    at /node_modules/firebase-admin/lib/auth/token-generator.js:135:44
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    // removed unimportant error lines from my own code
  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'
}




I think the issue is related to the internal nodejs crypto package on the new Ubuntu 22.04 LTS version.
so we need to open a bug ticket there to check, also I doubt it is the OpenSSL new version issue which was installed by default on Ubuntu 22.04 LTS. so yeah it is not firebase-admin issue, as everything is ok with me now on Ubuntu 20.04


Solution

for anyone who find the cnf file,
You can run the following command to get the location of openssl.cnf file:


openssl version -d

On my computer, the result is:


OPENSSLDIR: "/private/etc/ssl"

Finally, the path of openssl.cnf file:


/private/etc/ssl/openssl.cnf


Hence, we suggest you to 

comment out the lines providers = provider_sect` in the file `/etc/ssl/openssl.cnf` 

and restart application once. 

Fixed.