简体   繁体   English

node.js中的SSL证书错误

[英]SSL Certificate error in node.js

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 我的环境:最新的Puppeteer版本/ Windows 10

Set ignoreHTTPSErrors: true . 设置ignoreHTTPSErrors: true Beware: this will ignore all SSL errors. 注意:这将忽略所有SSL错误。

'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');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM