最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - SSL Certificate error in node.js - Stack Overflow

programmeradmin6浏览0评论

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('', {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

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

Share Improve this question edited Sep 24, 2017 at 14:13 Ori Marko 58.8k26 gold badges152 silver badges257 bronze badges asked Sep 24, 2017 at 14:12 NoahNoah 6812 gold badges8 silver badges17 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 18

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');
发布评论

评论列表(0)

  1. 暂无评论