添加证书安装路径

This commit is contained in:
wuchangming 2016-05-10 19:19:58 +08:00
parent 5537b28ffc
commit 3cb4c19cb2
6 changed files with 42 additions and 2 deletions

View File

@ -44,6 +44,8 @@ Mac 下
第三步设置手机的HTTP代理代理IP地址设置为PC的IP地址端口为`spy-debugger`的启动端口(默认端口9888)。
第四步手机浏览器访问http://spydebugger.com/cert 安装证书。
第四步:用手机浏览器访问你要调试的页面即可。
## 自定义选项

View File

@ -1,6 +1,8 @@
'use strict';
var SPY_WEINRE_DOMAIN = 'spyweinrefortest.com';
var SPY_DEBUGGER_DOMAIN = 'spydebugger.com';
var config = exports;
config.SPY_WEINRE_DOMAIN = SPY_WEINRE_DOMAIN;
config.SPY_WEINRE_DOMAIN = SPY_WEINRE_DOMAIN;
config.SPY_DEBUGGER_DOMAIN = SPY_DEBUGGER_DOMAIN;

View File

@ -7,6 +7,8 @@ var zlib = require('zlib');
var through = require('through2');
var config = require('../config/config');
var htmlUtil = require('../util/htmlUtil');
var path = require('path');
var fs = require('fs');
module.exports = {
createProxy: function createProxy(_ref) {
@ -31,6 +33,21 @@ module.exports = {
}
},
requestInterceptor: function requestInterceptor(rOptions, req, res, ssl, next) {
if (rOptions.hostname === config.SPY_DEBUGGER_DOMAIN && rOptions.path === '/cert') {
var userHome = process.env.HOME || process.env.USERPROFILE;
var certPath = path.resolve(userHome, './node-mitmproxy/node-mitmproxy.ca.crt');
try {
var fileString = fs.readFileSync(certPath);
res.setHeader('Content-Type', 'application/x-x509-ca-cert');
res.end(fileString.toString());
} catch (e) {
console.log(e);
res.end('please create certificate first!!');
}
next();
return;
}
if (rOptions.hostname === config.SPY_WEINRE_DOMAIN) {
rOptions.protocol = 'http:';
rOptions.hostname = '127.0.0.1';

View File

@ -1,6 +1,6 @@
{
"name": "spy-debugger",
"version": "2.0.4",
"version": "2.0.5",
"description": "web page one-stop remote network debugger",
"main": "lib/index.js",
"scripts": {

View File

@ -1,4 +1,6 @@
const SPY_WEINRE_DOMAIN = 'spyweinrefortest.com';
const SPY_DEBUGGER_DOMAIN = 'spydebugger.com';
var config = exports;
config.SPY_WEINRE_DOMAIN = SPY_WEINRE_DOMAIN;
config.SPY_DEBUGGER_DOMAIN = SPY_DEBUGGER_DOMAIN;

View File

@ -5,6 +5,8 @@ const zlib = require('zlib');
const through = require('through2');
const config = require('../config/config');
const htmlUtil = require('../util/htmlUtil');
const path = require('path');
const fs = require('fs');
module.exports = {
@ -29,6 +31,21 @@ module.exports = {
}
},
requestInterceptor: (rOptions, req, res, ssl, next) => {
if (rOptions.hostname === config.SPY_DEBUGGER_DOMAIN && rOptions.path === '/cert'){
var userHome = process.env.HOME || process.env.USERPROFILE;
var certPath = path.resolve(userHome, './node-mitmproxy/node-mitmproxy.ca.crt');
try {
var fileString = fs.readFileSync(certPath);
res.setHeader('Content-Type', 'application/x-x509-ca-cert');
res.end(fileString.toString());
} catch (e) {
console.log(e);
res.end('please create certificate first!!');
}
next();
return;
}
if (rOptions.hostname === config.SPY_WEINRE_DOMAIN) {
rOptions.protocol = 'http:'
rOptions.hostname = '127.0.0.1'