Using openssl s_client to manually fetch data through HTTPS tunnel

928 Views Asked by At

I have an interesting requirement to connect using openssl s_client to https website through https tunnel.

I have managed to connect through this proxy (proxy_host.com) to my netcat listener on target_host.com and send a message from it which gets relayed correctly to openssl client.

However, when I try to send GET / HTTP/1.1 followed by two enter's nothing gets sent (or nothing reaches target_host.

Below is what I'm currently working with:

echo "CONNECT target_host.com:443 HTTP/1.1\r\nHost:proxy_host.com\r\nConnection: Keep-Alive\r\n\r\n" | openssl s_client -ign_eof -connect proxy_host.com:443

To which I get only :

HTTP/1.0 200 
Connection Established 
Proxy-agent: Apache/2.2.15 (Red Hat)

I had to add Host header because that's the requirement of my proxy. Ultimately, I want to send a GET request to a webserver but I'm using nc to see what is getting through.

1

There are 1 best solutions below

0
On

This was actually easier than I thought using curl as below:

curl --proxy-insecure --proxy proxy_host.com:443 --proxy-header "Host: proxy_host.com" -k https://target_host.com:443