Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on homework assignment for my college. Task is to fetch web page on HTTPS using nc (netcat).

To fetch a page over HTTP, I do this:

cat request.txt | nc -w 5 <someserver> 80

In request.txt I have HTTP 1.1 request

GET / HTTP/1.1
Host: <someserver>

Now... This works fine. How can I fetch web page that uses HTTPS?

I get page certificate like this. And this is the point in which I'm stuck

openssl s_client -connect <someserver>:443
share|improve this question

closed as off-topic by Sven Dec 9 '14 at 8:18

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – Sven
If this question can be reworded to fit the rules in the help center, please edit the question.

socat - OPENSSL would work, but that's probably not your assignment. – Tobu Jan 12 '10 at 21:19
s/collage/college/, s/witch/which/ – Jukka Dahlbom Dec 20 '12 at 8:39
up vote 24 down vote accepted

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
share|improve this answer
I mean, unless your assignment is to write some code that does the SSL. That would be StackOverflow territory :) – Bill Weiss Jan 12 '10 at 20:44
I've tried this, but I do not get what the server send back to me in stdout... – Dog eat cat world Feb 17 '15 at 22:24

ncat --ssl from the nmap package worked well for me:

printf 'GET / HTTP/1.1\r\nHost:\r\n\r\n' | ncat --ssl 443

Same on Super User:

share|improve this answer
is there any way to take your command and pass username and password commands into it for https sites that require authentication? – user53029 Mar 16 at 12:52
@user53029 I think not for most websites, where authentication works by filling a form and giving you a session cookies. Unless it is one of the very few websites that uses other methods of authentication like You could also manually fill the form, and then send the cookie while it is valid. Or if you are desperate use… – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Mar 16 at 12:58

You probably want to use stunnel.

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

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

share|improve this answer
stunnel + nc would work, I suppose. Good thought. – Bill Weiss Jan 13 '10 at 15:56

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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.