Re: [go-nuts] HTTPS proxy issue using CONNECT method

2022-12-04 Thread Mauro Monteiro
Hello Sean

The proxy is a HTTPS proxy which exposes an endpoint that ONLY accepts HTTP 
CONNECT method. The code checks with the HTTP method informed is CONNECT 
and then it tries to establish the TCP connection with the target informed. 
Otherwise the request is rejected. Therefore, the proxy is ALWAYS HTTPS 
however it should be able to relay request to HTTP or HTTPS targets.

Mauro

On Saturday, December 3, 2022 at 7:34:44 PM UTC se...@liao.dev wrote:

> How are you setting the proxy?
>
> - sean
>
> On Sat, Dec 3, 2022, 16:46 Mauro Monteiro  wrote:
>
>> Hello all,
>>
>> I have been facing an issue when I try to create a HTTP client which 
>> needs to connect through a HTTPS proxy using the HTTP CONNEC method. I know 
>> that it can be achieved setting my own http.Transport object. However the 
>> issue seems to be in the current implementation of /net/http/transport.go 
>> code.
>>
>> In my environment, I am developing a HTTP client which ALWAYS use a HTTPS 
>> proxy using HTTP CONNECT method. This client is allowed to reach HTTP or 
>> HTTPS targets. Therefore, I noticed that when I try to reach a HTTPS 
>> target, the the transport layer works as expected and it uses the HTTP 
>> CONNECT method. However, when I try to reach a HTTP target, the transport 
>> does not use the CONNECT  method.
>>
>> Looking at the transport.go code, I realized that the check to use the 
>> CONNECT method is based on the protocol of the target instead of being on 
>> the protocol of the proxy URL. Below is a link showing that:
>>
>> 1. HTTP check
>>
>>
>> https://cs.opensource.google/go/go/+/refs/tags/go1.9.5:src/net/http/transport.go;l=1092
>>
>> 2. HTTPS check
>>
>>
>> https://cs.opensource.google/go/go/+/refs/tags/go1.9.5:src/net/http/transport.go;l=1099
>>
>> As can be seen on the links above, the condition is based on cm 
>> 
>> .targetScheme 
>> 
>>  instead 
>> of cm 
>> 
>> .proxyURL 
>> 
>> .Scheme 
>> .
>>  
>> Is it a bug?
>>
>> *Go version: go version go1.19.3 linux/amd64*
>>
>> Mauro
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/d06cd78b-c012-425f-8b5e-52d4bd7a3cbcn%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3f27116a-a2d7-454b-b269-7aaa395e1e4cn%40googlegroups.com.


Re: [go-nuts] HTTPS proxy issue using CONNECT method

2022-12-03 Thread 'Sean Liao' via golang-nuts
How are you setting the proxy?

- sean

On Sat, Dec 3, 2022, 16:46 Mauro Monteiro  wrote:

> Hello all,
>
> I have been facing an issue when I try to create a HTTP client which needs
> to connect through a HTTPS proxy using the HTTP CONNEC method. I know that
> it can be achieved setting my own http.Transport object. However the issue
> seems to be in the current implementation of /net/http/transport.go code.
>
> In my environment, I am developing a HTTP client which ALWAYS use a HTTPS
> proxy using HTTP CONNECT method. This client is allowed to reach HTTP or
> HTTPS targets. Therefore, I noticed that when I try to reach a HTTPS
> target, the the transport layer works as expected and it uses the HTTP
> CONNECT method. However, when I try to reach a HTTP target, the transport
> does not use the CONNECT  method.
>
> Looking at the transport.go code, I realized that the check to use the
> CONNECT method is based on the protocol of the target instead of being on
> the protocol of the proxy URL. Below is a link showing that:
>
> 1. HTTP check
>
>
> https://cs.opensource.google/go/go/+/refs/tags/go1.9.5:src/net/http/transport.go;l=1092
>
> 2. HTTPS check
>
>
> https://cs.opensource.google/go/go/+/refs/tags/go1.9.5:src/net/http/transport.go;l=1099
>
> As can be seen on the links above, the condition is based on cm
> 
> .targetScheme
> 
>  instead
> of cm
> 
> .proxyURL
> 
> .Scheme
> .
> Is it a bug?
>
> *Go version: go version go1.19.3 linux/amd64*
>
> Mauro
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/d06cd78b-c012-425f-8b5e-52d4bd7a3cbcn%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAGabyPrBxj2m9kgNZrL5k3maGBu2Ljb%2B%3DONe2m-kr7Z8K3ArHA%40mail.gmail.com.


[go-nuts] HTTPS proxy issue using CONNECT method

2022-12-03 Thread Mauro Monteiro
Hello all,

I have been facing an issue when I try to create a HTTP client which needs 
to connect through a HTTPS proxy using the HTTP CONNEC method. I know that 
it can be achieved setting my own http.Transport object. However the issue 
seems to be in the current implementation of /net/http/transport.go code.

In my environment, I am developing a HTTP client which ALWAYS use a HTTPS 
proxy using HTTP CONNECT method. This client is allowed to reach HTTP or 
HTTPS targets. Therefore, I noticed that when I try to reach a HTTPS 
target, the the transport layer works as expected and it uses the HTTP 
CONNECT method. However, when I try to reach a HTTP target, the transport 
does not use the CONNECT  method.

Looking at the transport.go code, I realized that the check to use the 
CONNECT method is based on the protocol of the target instead of being on 
the protocol of the proxy URL. Below is a link showing that:

1. HTTP check

https://cs.opensource.google/go/go/+/refs/tags/go1.9.5:src/net/http/transport.go;l=1092

2. HTTPS check

https://cs.opensource.google/go/go/+/refs/tags/go1.9.5:src/net/http/transport.go;l=1099

As can be seen on the links above, the condition is based on cm 

.targetScheme 

 instead 
of cm 

.proxyURL 

.Scheme 
.
 
Is it a bug?

*Go version: go version go1.19.3 linux/amd64*

Mauro

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d06cd78b-c012-425f-8b5e-52d4bd7a3cbcn%40googlegroups.com.