Ssl – curl succeeds on an https request, wget does not

curlsslwget

When I run curl from the command line

curl "https://example.com"

It succeeds immediately, returning the result of the request.

When I run the same wget command

wget https://example.com

It eventually times out with "Unable to establish SSL connection." without any specific error message. It connects, but can't do the SSL handshake. I tried with --no-check-certificate but that made no difference – it appears to be timeout related.

However:

wget http://example.com

works fine (HTTP vs HTTPS).

This is also affecting the PHP's "file()" method call.

My question is, what would cause curl to succeed in retrieving a page (for all sites in our domain) but not wget or the php interpreter? This is a new issue over the weekend, the server was fine before.

(Operating system is Red Hat Enterprise Linux 6.4)

Best Answer

This seems like an issue with choosing the SSL protocol. For some reason the server is picky about the protocol. Some clients happen to make the correct guess, others don't.

With wget, try eg. --secure-protocol=tlsv1 or --secure-protocol=sslv3. For more details, see GNU Wget man page.

With PHP, see this question on SO.

Related Topic