Handshake Failure: SSL Alert number 40
Found your question while searching for the exact same problem (curl
succeeds to connect while openssl
fails with alert number 40
).
It might be related to a server with several virtual hosts to serve, and you need to tell which host you want to connect to, to let the TLS handshake succeed.
Specify the exact host name you want with -servername
parameter. E.g:
openssl s_client -connect yourserver.domain.com:443 -servername yourserver.domain.com