Error: SSL Error: SELF_SIGNED_CERT_IN_CHAIN' while using npm in Node.js image

Solution Verified - Updated -

Issue

  • ubi8/Node.js 18 build results in the following SELF_SIGNED_CERT_IN_CHAIN issue:

    2024-07-31T16:29:56.115073554-04:00 Pulling image registry.access.redhat.com/ubi8/nodejs-18:latest ...
    2024-07-31T16:29:56.115750069-04:00 Trying to pull registry.access.redhat.com/ubi8/nodejs-18:latest...
    2024-07-31T16:29:57.749827781-04:00 Getting image source signatures
    2024-07-31T16:29:57.749897413-04:00 Copying blob sha256:71ea029fdcc643be6a4b3dcf9a384e865d247b06f8a496922334008229a8e738
    2024-07-31T16:29:57.749916133-04:00 Copying blob sha256:376a7503a7e3f4f0174eab5f3cc8b99d957df631e9b39007ff8d3c38b15fb498
    2024-07-31T16:29:57.749925445-04:00 Copying blob sha256:d8955d3e8e04900a695f484cedfd2fb469e4965201c5b6e7dc70afbe15a612e8
    2024-07-31T16:30:09.268642698-04:00 Copying config sha256:bd26ee404c7b6d3a38dad08b666ce80658859a363592c0bdab8fa895e1337ba2
    2024-07-31T16:30:09.269669390-04:00 Writing manifest to image destination
    2024-07-31T16:30:09.288208756-04:00 Adding transient rw bind mount for /run/secrets/rhsm
    2024-07-31T16:30:09.288960886-04:00 [1/2] STEP 1/3: FROM registry.access.redhat.com/ubi8/nodejs-18:latest
    2024-07-31T16:30:09.295135277-04:00 [1/2] STEP 2/3: COPY package.json package-lock.json* ./
    2024-07-31T16:30:10.150563158-04:00 --> 8c35388dcb8a
    2024-07-31T16:30:10.154382724-04:00 [1/2] STEP 3/3: RUN if [ -f package-lock.json ]; then npm ci;   else npm install;   fi
    2024-07-31T16:31:21.458887226-04:00 npm ERR! code SELF_SIGNED_CERT_IN_CHAIN
    2024-07-31T16:31:21.459087739-04:00 npm ERR! errno SELF_SIGNED_CERT_IN_CHAIN
    2024-07-31T16:31:21.460143518-04:00 npm ERR! request to https://registry.npmjs.org/vary/-/vary-1.1.2.tgz failed, reason: self signed certificate in certificate chain
    2024-07-31T16:31:21.462679046-04:00 
    2024-07-31T16:31:21.462744262-04:00 npm ERR! A complete log of this run can be found in: /opt/app-root/src/.npm/_logs/2024-07-31T20_30_10_463Z-debug-0.log
    2024-07-31T16:31:21.597870344-04:00 error: build error: building at STEP "RUN if [ -f package-lock.json ]; then npm ci;   else npm install;   fi": while running runtime: exit status 1
    
  • Sample nodejs/python application deployment is failing due to following errors,

    npm ERR! errno SELF_SIGNED_CERT_IN_CHAIN
    npm ERR! request to https://registry.npmjs.org/vary/-/vary...ailed, reason: self signed certificate in certificate chain
    
    Could not fetch URL https://pypi.org/simple/flask/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/flask/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1129)'))) - skipping
    

Environment

  • Red hat OpenShift Container Platform (OCP)
    • 4.x
  • Node.js 16/18

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content