簡體   English   中英

node.js中的SSL證書錯誤

[英]SSL Certificate error in node.js

我和木偶戲有問題了。 所以我想要做的是啟動一個網站並登錄。 但是,此網站嘗試加載由於其不安全而被阻止的資源。 運行代碼后,我收到此錯誤消息,代碼停止運行:

(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.

我的代碼:

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

這就是鉻消費者推出的產品:

Failed to load resource: net::ERR_INSECURE_RESPONSE

我的環境:最新的Puppeteer版本/ Windows 10

設置ignoreHTTPSErrors: true 注意:這將忽略所有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