mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-19 15:44:22 +00:00
24 lines
727 B
JavaScript
24 lines
727 B
JavaScript
const AnyProxy = require('../proxy');
|
|
const exec = require('child_process').exec;
|
|
|
|
if (!AnyProxy.utils.certMgr.ifRootCAFileExists()) {
|
|
AnyProxy.utils.certMgr.generateRootCA((error, keyPath) => {
|
|
// let users to trust this CA before using proxy
|
|
if (!error) {
|
|
const certDir = require('path').dirname(keyPath);
|
|
console.log('The cert is generated at', certDir);
|
|
const isWin = /^win/.test(process.platform);
|
|
if (isWin) {
|
|
exec('start .', { cwd: certDir });
|
|
} else {
|
|
exec('open .', { cwd: certDir });
|
|
}
|
|
} else {
|
|
console.error('error when generating rootCA', error);
|
|
}
|
|
});
|
|
} else {
|
|
// clear all the certificates
|
|
// AnyProxy.utils.certMgr.clearCerts()
|
|
}
|