curl-unix-socket icon indicating copy to clipboard operation
curl-unix-socket copied to clipboard

add a feature for https

Open grimm26 opened this issue 10 years ago • 5 comments

Sometimes I want to check a port for an app that is forcing a redirect (301) to https. Is it possible to use https into the socket?

grimm26 avatar Apr 09 '15 14:04 grimm26

Done in https://github.com/Soulou/curl-unix-socket/commit/4aed38106006740b39d36f6aff04cff3816df2a7

Example of usage:

go run server_examples/https.go example.sock certpath.pem keypath.pem &
go build
./curl-unix-socket -https -k unix://example.sock:/

You need to create the cert/key before with OpenSSL for example.

Does it answer your need?

Soulou avatar Apr 09 '15 16:04 Soulou

I tried it on a socket for a puma web server I have running:

curl-unix-socket -k -https -v unix:///var/run/project/puma-2.sock:
Fail to connect to /var/run/project/puma-2.sock : tls: oversized record received with length 20527

grimm26 avatar Apr 09 '15 18:04 grimm26

What is the result of

curl-unix-socket -v unix:///var/run/project/puma-2.sock:

??

Soulou avatar Apr 09 '15 23:04 Soulou

$ curl-unix-socket -v unix:///var/run/project/puma-2.sock:
> GET  HTTP/1.1
> Socket: /var/run/project/puma-2.sock
> Content-Length: 0
>
< HTTP/1.1 301 Moved Permanently
< Content-Type: text/html
< Location: https:///

Works fine. I get a 301 cuz the app redirects to https, which is why I wanted the https :)

grimm26 avatar Apr 10 '15 14:04 grimm26

ok got it, I've to handle http to https redirection

Soulou avatar Apr 27 '15 22:04 Soulou