Sending HTTPS Requests through an upstream proxy with Fiddler - https

I already checked Fiddler - tunnelled http requests to port 443 and Fiddler2: Decrypt HTTPS traffic and Tunnel to host:443, but my question is different.
I do not want to use Fiddler as a Proxy for another program. Instead, I simply want to use Fiddler's Composer Tab to send a HTTPS request over an upstream proxy. My proxy configuration and authorization is correct; sending HTTP requests works just fine.
When I use Fiddler's Composer to send an HTTPS GET to https://google.com, it results in a time-out (HTTP 502 / [Fiddler] The connection to 'google.com' failed. Error: TimedOut (0x274c).).
When I send an HTTPS CONNECT to https://google.com, I get HTTP 502 / [Fiddler] DNS Lookup for failed.
Does anybody know how I can establish an HTTPS tunnel over my proxy and then send a GET request?

to establish the tunnel, you must use CONNECT to the proxy. You must also include the host header, which doubles the destination in the CONNECT request... e.g.
CONNECT www.google.com:443 HTTP/1.1
Host: www.google.com
etc
Once the tunnel is up (e.g. you get a 200 OK from the proxy) you need to go into TLS handshake before you can send the http request (which since it's over TLS is now https). e.g.
GET / HTTP/1.1
Host: www.google.com
etc.

Related

HTTPS over Socks5 server implementation

I am trying to implement a Socks5 server that could relay both HTTP and HTTPS traffic.
As the RFC1928 mentions, the following steps to establish a connection and forward the data must be taken :
Client sends a greeting message to the proxy.
Client & proxy authentication (assuming it is successful).
Client sends a request to the proxy to connect to the destination.
The proxy connects to the destination and sends back a response to the client to indicate a successful open tunnel.
The proxy reads the data from the client and forwards it to the destination.
The proxy reads the data from the destination and forwards it to the client.
So far, the proxy works as it should. It is able to relay HTTP traffic using its basic data forwarding mechanism. However, any request from the client to an HTTPS website will be aborted because of SSL/TLS encryption.
Is there another sequence/steps that should be followed to be able to handle SSL/TLS (HTTPS) traffic?
The sequence you have described is correct, even for HTTPS. When the client wants to send a request to an HTTPS server through a proxy, it will request the proxy to connect to the target server's HTTPS port, and then once the tunnel is established, the client will negotiate a TLS handshake with the target server, then send an (encrypted) HTTP request and receive an (encrypted) HTTP response. The tunnel is just a passthrough of raw bytes, the proxy has no concept of any encryption between the client and server. It doesn't care what the bytes represent, its job is just to pass them along as-is.

How to redirect Rest API requests from dev server to localhost using Fiddler

I have a dev server serving my rest API which is using SSL at https://api.stg.something.com
I also have the same API working from localhost at http://localhost:5000
Now i want with Fiddler to redirect every api request(POST,GET) to my dev server into localhost for debugging reasons
I added to FiddlerScript's static function OnBeforeRequest
if (oSession.HostnameIs("api.stg.iot.vodafoneinnovus.com")) oSession.host = "localhost:5000";
but that not seems to work. When i hit a request from Postman to lets say https://api.stg.something.com/api/stuff
i don't get the response and fiddler inspector says
fiddler.network.https> HTTPS handshake to localhost (for #6) failed. System.IO.IOException The handshake failed due to an unexpected packet format.
The fiddler trying to establish a Secure connection but localhost refuse it.
How can i go from https request to http in fiddler?

Does the secure cookie work on http request with 443 port?

Does a Cookie with the secure flag work on Http request with 443 port?
For example) http:443//www.example.com
And how about ssl on Http request with 443 port?
"Does a Cookie with the secure flag work on Http request with 443 port?"
-- No. A cookie with secure flag only works under HTTPS environment. HTTP request to port 443 (the default port of HTTPS) is still an HTTP, not HTTPS. Protocol is protocol, it won't be decided by which port is used.
According to RFC6265:
The Secure attribute limits the scope of the cookie to "secure"
channels (where "secure" is defined by the user agent). When a
cookie has the Secure attribute, the user agent will include the
cookie in an HTTP request only if the request is transmitted over a
secure channel (typically HTTP over Transport Layer Security (TLS)
HTTP request to port 443 is not transmitted over a secure channel.
I made a simple experiment, and the result is listed as below:
Make a web server, listen to port 443, with HTTP protocol. It works well.
On above server, return cookie without secure flag. The browser received the cookie and store it successfully.
On above server, return cookie with secure flag. The browser received the cookie, but ignore it automatically, as the current protocol is HTTP, not HTTPS.
"How about ssl on Http request with 443 port?"
-- There is no SSL on HTTP request with 443 port. 443 is a plain, normal number, there is nothing special for it. It's just being choosed as the default port of HTTPS, nothing more.

squid proxy to convert http requests to https

I am looking at achieving the following with squid proxy setup. When client sends a http request (say. http://, I would like my squid proxy to make this request into https and sends the request on behalf of the client and in turn will respond back to client unencrypted.
[client]---- http -----[squid proxy] --------https-----[server]
I would like to do this only for a certain set of URLS (dynamic list).
Can this be achieved?

Tinyproxy and Proxyfier combination

I have a VPS with Tinyproxy installed, and I have my PC configured with Proxyfier. Protocols SOCKSv4 and SOCKSv5 doesn't work for me, and I need HTTPS protocol. But when I choose HTTPS protocol I'm getting this error:
43:04] Error : the proxy server cannot establish connection with www.google.com:80
The error may indicate that the proxy server doesn't support SSL connections.
It means that the proxy can be used for web browsing but it cannot work with Proxifier.
The proxy server reply header is:
HTTP/1.0 403 Access violation
Server: tinyproxy/1.8.3
Content-Type: text/html
Connection: close
[43:04] Test failed.
Could you suggest me a possible solution? Maybe another program that work's like Proxifier or another Proxy that support https authentication and easy to get working.

Resources