Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Dec 242010
 

Use insecure SSL connections and transfers with curl

Answer:

If you have a self-signed SSL certificate with your server, and you want to connect to it using the curl command, you need to use the " -k/--insecure" option since curl only use the CA certificate bundle installed by default.

Example:

# curl -k https://localhost

Dec 232010
 

Show HTTP response using curl command

Answer:

curl is a very powerful tool for transferring data from or to a server, which support many protocols such as HTTP, HTTPS, FTP etc.

Example: Issue a HTTP request to a remote server.

# curl -v http://www.example.com

* About to connect() to www.example.com port 80 (#0)
*   Trying 192.0.32.10... connected
* Connected to www.example.com (192.0.32.10) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.5 (x86_64-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.15
> Host: www.example.com
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Apache
< Last-Modified: Fri, 30 Jul 2010 15:30:18 GMT
< ETag: "573c1-254-48c9c87349680"
< Accept-Ranges: bytes
< Content-Type: text/html; charset=UTF-8
< Connection: Keep-Alive
< Date: Wed, 22 Dec 2010 16:19:06 GMT
< Age: 817
< Content-Length: 596
...
Nov 292010
 

How to simulate curl using wget command?

Answer:

To simulate a simple curl command using wget, e.g. curl http://www.google.co.uk:

# wget -O- http://www.google.co.uk

To view the HTTP response header (i.e. more verbose), e.g. curl -v http://www.google.co.uk:

# wget -O- -S http://www.google.co.uk