nodeca / probe-image-size

Get image size without full download. Supported image types: JPG, GIF, PNG, WebP, BMP, TIFF, SVG, PSD, ICO.
MIT License
978 stars 77 forks source link

Error: unable to verify the first certificate #82

Closed thanhtoan1196 closed 8 months ago

thanhtoan1196 commented 8 months ago

Some links have this error, although it still opens fine in the browser.

Code:

const probe = require('probe-image-size');
(async () => {
    await probe("https://www.nylabone.com/-/media/project/oneweb/nylabone/images/dog101/activities-fun/10-great-small-dog-breeds/maltese-portrait.jpg")
})();

Logs:

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (node:_tls_wrap:1550:34)
    at TLSSocket.emit (node:events:514:28)
    at TLSSocket._finishInit (node:_tls_wrap:967:8)
    at ssl.onhandshakedone (node:_tls_wrap:743:12) {
  code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
}

Node.js v18.17.1
thanhtoan1196 commented 8 months ago

How to fix: Add options:

{ rejectUnauthorized: false }