nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.38k stars 3.88k forks source link

Can nwjs support some nodejs enviroment variables? such as NODE_EXTRA_CA_CERTS #6413

Open cecilpeng opened 6 years ago

cecilpeng commented 6 years ago

NWJS Version : nwjs 0.27.5 Operating System : win7

Expected behavior

My application support system proxy. Both developers and testers of our program need to run it with fiddler capturing all http(s) traffics. I hope nwjs support nodejs enviroment variables completely.

Actual behavior

It is different between nodejs and nwjs. nwjs throw error in the condition of ca-configured-tls .

How to reproduce

  1. Configure Fiddler to Decrypt HTTPS Traffic. Ref to http://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/DecryptHTTPS
  2. Configure Windows Client to trust Fiddler Root Certificate. Ref to http://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/TrustFiddlerRootCert
  3. Export fiddler ca to an pem file. Your can open Windows Certificate Manager, and find DO_NOT_TRUST_FiddlerRoot-CE, then export it in Base64 X.509 cer.
  4. Configure NODE_EXTRA_CA_CERTS with exported file of fiddler ca pem in the enviorment variables.
  5. Test in two cases: nodejs 9.0.0 and nwjs 0.27.5

nodejs code:

const request = require('request'); // npm i request first
request({
    url: 'https://www.baidu.com',
    proxy: 'http://127.0.0.1:8888'
}, (err) => {
    console.log(err); // Error: unable to verify the first certificate in nwjs
});
cecilpeng commented 6 years ago

nwjs sample: sample.zip

Christywl commented 6 years ago

I can reproduce this issue on Windows 10 with nwjs-sdk-v0.27.5.

image

Run it with nodejs:

const request = require('request'); // npm i request first
request({
    url: 'https://www.baidu.com',
    proxy: 'http://127.0.0.1:8888'
}, (err) => {
    console.log(err);
});

output: null