gr3p1p3 / transparent-proxy

41 stars 17 forks source link

Library broke https requests if I set upstream proxy with credentials #11

Open oneassasin opened 2 years ago

oneassasin commented 2 years ago

http requests work without problems, but https connections give an error I check in the firefox browser (SSL_ERROR_RX_RECORD_TOO_LONG error) If I set proxy without credentials - all connections works nice

const ProxyServer = require('transparent-proxy');

//init ProxyServer
const server = new ProxyServer({
  verbose: true,
  upstream: function () {
    // http proxy
    return 'login:password@some_ip_proxy:3128';
  },
});

//starting server on port 8080
server.listen(8080, '0.0.0.0', function () {
  console.log('TCP-Proxy-Server started!', server.address());
});
oneassasin commented 2 years ago

if need proxy with credentials for tests - write me to Telegram @bednyi_bogdan

oneassasin commented 2 years ago

@gr3p1p3 up )

gr3p1p3 commented 2 years ago

I tried with your proxy and CURL and it didnt work as well! Your Proxy returns an 200-Code response and then it seems to make something strange with the response. "curl -K" helped me to bring this to work!

Make sure is not a problem for your proxy! :)

mat-twg commented 2 years ago

Hi! Thanks for project! Im trying to implement simple proxy server with auth, and i got same issue, can you help me with curl log? without auth all works fine!

$ curl -vvv -x 127.0.0.1:8886 https://www.google.com
*   Trying 127.0.0.1:8886...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connected to 127.0.0.1 (127.0.0.1) port 8886 (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to www.google.com:443
> CONNECT www.google.com:443 HTTP/1.1
> Host: www.google.com:443
> User-Agent: curl/7.79.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection Established
<
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
*  CApath: none
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.3 (IN), TLS alert, protocol version (582):
{ [2 bytes data]
* error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Closing connection 0
curl: (35) error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version

Can you update examples about this case: browser_https->proxy_transparent->proxy_with_basic_auth->target

mat-twg commented 2 years ago

transparent-proxy -> http-proxy boilerplate

gr3p1p3 commented 2 years ago

Hi! Thanks for project! Im trying to implement simple proxy server with auth, and i got same issue, can you help me with curl log? without auth all works fine!

$ curl -vvv -x 127.0.0.1:8886 https://www.google.com
*   Trying 127.0.0.1:8886...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connected to 127.0.0.1 (127.0.0.1) port 8886 (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to www.google.com:443
> CONNECT www.google.com:443 HTTP/1.1
> Host: www.google.com:443
> User-Agent: curl/7.79.1
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection Established
<
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
*  CApath: none
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.3 (IN), TLS alert, protocol version (582):
{ [2 bytes data]
* error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Closing connection 0
curl: (35) error:1409442E:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version

Can you update examples about this case: browser_https->proxy_transparent->proxy_with_basic_auth->target

Try to deactivate security-alerts on your client.

gr3p1p3 commented 1 year ago

Is someone still having this issue?

gr3p1p3 commented 1 year ago

It was an Error rebuilding headers from payload for proxy with credentials! Update and try again.