‘unable to get local issuer certificate’ when following express-openid-connect- tutorial

  • Which SDK this is regarding: express-openid-connect
  • SDK Version: 2.2.1
  • Platform Version: Node 12.19.0
  • Code Snippets/Error Messages/Supporting Details/Screenshots:

Hello auth0 community,

I’m trying to follow the steps at https://auth0.com/blog/auth0-s-express-openid-connect-sdk to begin the process of working with auth0, nodejs, and express. I followed the ‘local dev’ guide to set up caddy and proxy to SSL.

My express app is throwing the following every time I try to access https://localhost/login (which should show an auth0 lock screen):

(node:48241) UnhandledPromiseRejectionWarning: AggregateError:
    RequestError: unable to get local issuer certificate
        at ClientRequest.<anonymous> (/Users/user/random-dev/api/node_modules/openid-client/node_modules/got/dist/source/core/index.js:953:111)
        at ClientRequest.origin.emit (/Users/user/random-dev/api/node_modules/openid-client/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
    RequestError: unable to get local issuer certificate
        at ClientRequest.<anonymous> (/Users/user/random-dev/api/node_modules/openid-client/node_modules/got/dist/source/core/index.js:953:111)
        at ClientRequest.origin.emit (/Users/user/random-dev/api/node_modules/openid-client/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
    at maybeSettle (/Users/user/random-dev/api/node_modules/p-some/index.js:31:11)
    at /Users/user/random-dev/api/node_modules/p-some/index.js:69:23
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:48241) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

It was working at some point prior. I triple-checked that my auth0 app details/credentials are accurate. Anyone encounter something similar to this or have any tips?

1 Like

UnhandledPromiseRejectionWarning originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). A rejected promise is like an exception that bubbles up towards the application entry point and causes the root error handler to produce that output. It usually happens in async await functions, and there’s an easy fix.

const functionName = async (arguments) => {
  try {
  // Your code here
  } catch (error) {
  // Handle rejection here
  }
};

A nice way to wait for several Promises to resolve to use the Promise.all function. It expects an Array of Promises, and produces a Promise that resolves to an Array containing the values that the individual Promises resolved to. Furthermore, it only resolves after the last Promise resolves. If any of its input Promises rejects, then the entire Promise.all expression rejects as well. It effectively “runs” all of its input processes “at the same time”, emulating the classic “fork-join” pattern.