alvarcarto / url-to-pdf-api

Web page PDF/PNG rendering done right. Self-hosted service for rendering receipts, invoices, or any content.
MIT License
7.01k stars 774 forks source link

ERR_CERT_AUTHORITY_INVALID #30

Closed thebetterjort closed 6 years ago

thebetterjort commented 6 years ago

In my corporation we have self-signed certs, which causes to throw errors. How do I disable SSL?

2017-10-11T20:44:32.919Z - info: [pdf-core.js] Set browser viewport..
2017-10-11T20:44:32.920Z - info: [pdf-core.js] Emulate @media screen..
2017-10-11T20:44:32.921Z - info: [pdf-core.js] Goto url http://google.com ..
2017-10-11T20:44:33.689Z - error: [pdf-core.js] Error when rendering page: Error: SSL Certificate error: ERR_CERT_AUTHORITY_INVALID
2017-10-11T20:44:33.689Z - error: [pdf-core.js] Error: SSL Certificate error: ERR_CERT_AUTHORITY_INVALID
    at NavigatorWatcher.waitForNavigation (/usr/src/app/node_modules/puppeteer/lib/NavigatorWatcher.js:73:20)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
2017-10-11T20:44:33.690Z - info: [pdf-core.js] Closing browser..
2017-10-11T20:44:33.708Z - error: [error-logger.js] Request headers: host=localhost:9000, user-agent=Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0, accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, accept-language=en-US,en;q=0.5, accept-encoding=gzip, deflate, connection=keep-alive, upgrade-insecure-requests=1
2017-10-11T20:44:33.708Z - error: [error-logger.js] Request parameters:
2017-10-11T20:44:33.709Z - error: [error-logger.js] Request body:
2017-10-11T20:44:33.710Z - error: [error-logger.js] Error: SSL Certificate error: ERR_CERT_AUTHORITY_INVALID
    at NavigatorWatcher.waitForNavigation (/usr/src/app/node_modules/puppeteer/lib/NavigatorWatcher.js:73:20)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7) 'Error: SSL Certificate error: ERR_CERT_AUTHORITY_INVALID\n    at NavigatorWatcher.waitForNavigation (/usr/src/app/node_modules/puppeteer/lib/NavigatorWatcher.js:73:20)\n    at <anonymous>\n    at process._tickCallback (internal/process/next_tick.js:188:7)'
GET /api/render?url=http://google.com&pdf.margin.top=2cm&pdf.margin.right=2cm&pdf.margin.bottom=2cm&pdf.margin.left=2cm 500 1021.139 ms - -
thebetterjort commented 6 years ago

in pdf-core.js I've added line 34 to include ignoreHTTPSErrors: true,

this fixes the issue.

  const browser = await puppeteer.launch({
    headless: true,
    ignoreHTTPSErrors: true,
    args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox'],
  });

Is this a feature in which you would like to support?

kimmobrunfeldt commented 6 years ago

ignoreHttpsErrors option now in master.