node-http-mitm-proxy icon indicating copy to clipboard operation
node-http-mitm-proxy copied to clipboard

The example in readme cannot work

Open CHENGCHANGHU opened this issue 2 years ago • 4 comments

I install node-http-mitm-proxy in a node project, paste the example code to file index.js, and run the file. Then I open browser and type www.google.com. But I cannot see log in the terminal.

CHENGCHANGHU avatar Sep 14 '23 10:09 CHENGCHANGHU

Yeah, their CA is not generating automatically anymore

NN-Binary avatar Sep 18 '23 12:09 NN-Binary

Yeah, their CA is not generating automatically anymore

thanks

CHENGCHANGHU avatar Oct 18 '23 02:10 CHENGCHANGHU

@CHENGCHANGHU @jasonk @joeferner @NN-Binary I am facing issues in https: . http is working fine. I have pasted code below that i am using and error that i am facing. I can't figure out this . please help me with it. My ultimate requirement is to read https: request and modify it on my node server

my code is ; const port = 8081;

const Proxy = require('http-mitm-proxy').Proxy; const path = require('path') const fs = require('fs') const proxy = new Proxy(); var options = { keyFile: path.resolve('/projects/testmui-api/.http-mitm-proxy/keys/ca.private.key'), certFile: path.resolve('/projects/testmui-api/.http-mitm-proxy/certs/ca.pem'), } proxy.onError((ctx, err, errorKind) => { // ctx may be null console.log(ctx, ' error cert') const url = ctx?.clientToProxyRequest?.url || ""; console.error(${errorKind} on ${url}:, err); }); proxy.onCertificateRequired = function(hostname, callback) { return callback(null, { keyFile: path.resolve('/projects/testmui-api/.http-mitm-proxy/keys/', hostname + '.key'), certFile: path.resolve('/projects/testmui-api/.http-mitm-proxy/certs/', hostname + '.pem') }); }; // proxy.onCertificateRequired = function(hostname, callback) { // return callback(null, { // keyFile: path.resolve('/projects/testmui-api/.http-mitm-proxy/keys/', hostname + '.key'), // certFile: path.resolve('/projects/testmui-api/.http-mitm-proxy/certs/', hostname + '.pem'), // hosts: ["*.mydomain.com"] // }); // }; proxy.onCertificateMissing = function(ctx, files, callback) { console.log('Looking for "%s" certificates', ctx.hostname); console.log('"%s" missing', ctx.files.keyFile); console.log('"%s" missing', ctx.files.certFile); }; proxy.onRequest((ctx, callback) => { console.log('REQUEST: http://' + ctx.clientToProxyRequest.headers.host + ctx.clientToProxyRequest.url); return callback(); });

proxy._createHttpsServer(options) proxy.listen({port}) console.log(listening on ${port});

Error screenshots: image

Srijan67 avatar Oct 19 '23 10:10 Srijan67

Yeah, their CA is not generating automatically anymore

Any ideas how to fix that?

Kalisto93 avatar Oct 28 '23 23:10 Kalisto93