Skip to content

Instantly share code, notes, and snippets.

@nanusdad
Last active June 18, 2024 06:53

Revisions

  1. nanusdad renamed this gist Jun 18, 2024. 1 changed file with 0 additions and 0 deletions.
  2. nanusdad created this gist Jun 18, 2024.
    15 changes: 15 additions & 0 deletions intermediate-certificate-error.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    # How to resolve - unable to verify the first certificate in NodeJS
    ## Connect using SSL to ascertain the error
    `openssl s_client -connect foo.badssl.com:443 -servername foo.badssl.com`
    ## Save output to tmp file
    `openssl s_client -connect foo.badssl.com:443 -servername foo.badssl.com | tee /tmp/logcertfile`
    ## Find issuer and CRT file
    `openssl x509 -in /tmp/logcertfile -noout -text | grep -i "issuer"`
    ## Get the intermediate certificate from issues
    `curl --output sectigo.crt http://crt.sectigo.com/SectigoRSAOrganizationValidationSecureServerCA.crt`
    ## Convert to pem file
    `openssl x509 -inform DER -in sectigo.crt -out sectigo.pem -text`
    ## Use pem file in NODE_EXTRA_CA_CERTS environment variables
    `PORT=3000 ROOT_URL=https://prod.domain.com NODE_EXTRA_CA_CERTS="/home/admin/sectigo.pem" node main.js`

    [Read more on stackoverflow ...](https://stackoverflow.com/questions/31673587/error-unable-to-verify-the-first-certificate-in-nodejs)