Open jacob-cross99 opened 5 years ago
I'm working on a proxy that removes ads from the users browser. I've noticed that whenever I visit a site that translates google requests the proxy crashes with the error PEN_read_bio:no start line and there's no .pem data in the certs folder.
Ex: http://www.prodisney.ru/index.php?page=clones.php
import Proxy from 'http-mitm-proxy' import { PROXY_HOST, PROXY_PORT } from '../config' import { hasMiddleware, runMiddleware } from '../middleware' const proxy = Proxy() proxy .use(Proxy.gunzip) .onRequest((ctx, callback) => { const { url, method, headers } = ctx.clientToProxyRequest let chunks = [] let path if(headers && headers.host) path = headers.host.toLowerCase() + url.toLowerCase() runMiddleware(path, method, ctx, undefined, () => { ctx .onResponseData((ctx, chunk, callback) => { if(!hasMiddleware(path)) return callback(null, chunk) chunks.push(chunk) callback(null, null) }) .onResponseEnd((ctx, callback) => { if(!hasMiddleware(path)) return callback() runMiddleware(path, method, ctx, Buffer.concat(chunks).toString(), () => ctx.proxyToClientResponse.end(Buffer.concat(chunks))) }) callback() }) }) export default function listen() { proxy.listen({ host: PROXY_HOST, port: PROXY_PORT, sslCaDir: process.cwd() + '/hosts' }) }
this should be resolved now, upgrade to >=0.9.0
I'm working on a proxy that removes ads from the users browser. I've noticed that whenever I visit a site that translates google requests the proxy crashes with the error PEN_read_bio:no start line and there's no .pem data in the certs folder.
Ex: http://www.prodisney.ru/index.php?page=clones.php