Connecting to HTTPS with netcat (nc) [closed]

Solution 1:

nc doesn't do https. openssl s_client is as close as you'll get. Do something like this:

$ cat request.txt | openssl s_client -connect server:443

Solution 2:

ncat --ssl

sudo apt-get install nmap
printf 'GET / HTTP/1.1\r\nHost: github.com\r\n\r\n' | ncat --ssl github.com 443

Same on Super User: https://superuser.com/questions/346958/can-the-telnet-or-netcat-clients-communicate-over-ssl

Tested on Ubuntu 18.04.

Solution 3:

You probably want to use stunnel.

A GNU program allowing to encrypt arbitrary TCP connections inside Secure Sockets Layer (SSL).

http://www.stunnel.org

It's very UNIX-y. One great tool for one simple task.

Solution 4:

Ask the prof or TA for assistance. You would never try to do HTTPS over netcat in the real world (openssl s_client would be my first-line tool of choice, but there are other options) so the chances of finding the "right" answer that the prof wants by asking people in the real world is low. I'd probably go over all the slides/notes from the lectures; typically these sorts of "impossible" questions are actually answered in the lectures, and asked just to see who is actually paying attention in class.