I´m having an issue with puppeteer. So what I want to do is to launch a website and login. However, this website tries to load a resource which is blocked because its insecure. After running the code I get this error message and the code stops running:
(node:11684) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: SSL Certificate error: ERR_CERT_COMMON_NAME_INVALID
(node:11684) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
My code:
'use strict';
const puppeteer = require('puppeteer');
async function Login(username, password){
const browser = await puppeteer.launch({
headless: false
});
const page = await browser.newPage();
await page.goto('https://shop.adidas.ae/en/customer/account/login', {waitUntil: 'networkidle'});
/*await page.type(username);
await page.focus('#pass');
await page.type(password);
await page.click('#send2');*/
await browser.close();
}
Login('xxx', 'xxx');
This is what the chrome consule puts out:
Failed to load resource: net::ERR_INSECURE_RESPONSE
My enviroment: Latest Puppeteer version / Windows 10
How do you resolve certificate errors in a node js app with SSL calls? The easiest solution to resolve these errors is to use the “rejectUnauthorized” option shown below. However, this method is unsafe because it disables the server certificate verification, making the Node app open to MITM attack.
Set ignoreHTTPSErrors: true
. Beware: this will ignore all SSL errors.
'use strict';
const puppeteer = require('puppeteer');
async function Login(username, password){
const browser = await puppeteer.launch({
headless: false,
ignoreHTTPSErrors: true
});
const page = await browser.newPage();
await page.goto('https://shop.adidas.ae/en/customer/account/login', {waitUntil: 'networkidle'});
/*await page.type(username);
await page.focus('#pass');
await page.type(password);
await page.click('#send2');*/
await browser.close();
}
Login('xxx', 'xxx');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With