0

Does anyone know why curl with -k (--insecure) option and -I for show headers still shows the html response and not the headers as expected?

Working as expected:

$ curl -I https://validsslcert.example.com
HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
...

$ curl -k -I https://validsslcert.example.com
HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
...

$ curl -k https://invalidcert.example.com
<br />
...

NOT working as expected:

$ curl -k -I https://invalidcert.example.com
<br />
<br />
<br />
<center><h2>Maintenance</h2></center>

It doesn't really matter here what I'm doing, but I'm testing what headers get set to identify different backend acl logic on haproxy.

I would expect curl to allow me to make an insecure connection (invalid certificate) and still return the headers?

1
  • I can't answer why curl does that (possibly it's a bug), but have you tried -v instead of -I if you want to see the headers? Does that also fail?
    – dirkt
    Jan 11, 2021 at 13:37

1 Answer 1

0

Works for me without any problems. Fails without -k:

$ curl -I https://self-signed.badssl.com/
curl: (60) SSL certificate problem: self signed certificate

But succeeds with -k and also shows headers due to -I:

$ curl -k -I https://self-signed.badssl.com/
HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Mon, 11 Jan 2021 15:16:31 GMT
Content-Type: text/html
Content-Length: 502
Last-Modified: Tue, 24 Mar 2020 00:15:54 GMT
Connection: keep-alive
ETag: "5e79513a-1f6"
Cache-Control: no-store
Accept-Ranges: bytes

Maybe the server in question is simply broken and does not send any HTTP headers (i.e. HTTP/0.9 style response)?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .