uncss/uncss

Add option to ignore TLS/SSL errors

Open

#359 建立於 2018年1月31日

在 GitHub 查看
 (9 留言) (0 反應) (0 負責人)JavaScript (9,386 star) (403 fork)batch import
enhancementhelp wanted

描述

Hi, I'm using the latest uncss and ran uncss https://sample.dev > /path/to/stylesheet.css to remove unused styles from my local server with HTTPS and self signed certificates. but I got an TLS-related error.

Node version: v9.4.0

UnhandledPromiseRejectionWarning: Error: self signed certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1041:34)
    at TLSSocket.emit (events.js:160:13)
    at TLSSocket._finishInit (_tls_wrap.js:638:8)
(node:34329) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:34329) [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.

I think an option for self-signed certificate should be provided or ignoring TLS related errors should be applied with something like these options in src/utility.js at Line 112-113 when a request is issued.

request({
  url: filename,
  headers: { 'User-Agent': 'UnCSS' },
  // ignore TLS related errors
  rejectUnauthorized: false,
  strictSSL: false,
  // OR just specify self-signed cert and key
  agentOptions: {
    cert: fs.readFileSync("/path/to/cert.crt")
    key: fs.readFileSync("/path/to/key.key")
  }
}, callback);

@giakki, @RyanZim What do you guys think about this?

貢獻者指南