Learn how to effectively troubleshoot and resolve the `curl cannot handshake` error when connecting to a Node.js HTTPS server, ensuring seamless communication with SSL/TLS protocols.
---
This video is based on the question https://stackoverflow.com/q/67001389/ asked by the user 'IdiakosE Sunday' ( https://stackoverflow.com/u/5134605/ ) and on the answer https://stackoverflow.com/a/67017366/ provided by the user 'dave_thompson_085' ( https://stackoverflow.com/u/2868801/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.
Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: curl cannot handshake https server created with Nodejs v14.16.0 tls.createSecureContext
Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l...
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license.
If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com.
---
Resolving the curl cannot handshake Issue with Node.js HTTPS Server
When developing applications using Node.js, you may encounter issues while setting up an HTTPS server. One such common issue is the failure of curl to establish a secure connection, which presents itself through the error message: curl: (35) error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure. In this guide, we will explore the reasons behind this issue and provide a step-by-step guide to resolving it.
Understanding the Problem
The error message you encounter is typically associated with problems in the SSL/TLS handshake process between the client (in this case, curl) and the server. This can be caused by several factors, including improper SSL/TLS settings, unrecognized cipher suites, or misconfigured certificates. If you are using Node.js v14.16.0 alongside Let's Encrypt for SSL certificates, let's identify potential culprits and rectify them.
The curl Command Output
When you run the command:
[[See Video to Reveal this Text or Code Snippet]]
The output suggests the following:
An unsuccessful SSL handshake.
A likely mismatch in the supported SSL/TLS versions or cipher suites.
Solution: Configuring the HTTPS Server Correctly
To resolve the handshake issue, we need to modify the server configuration. The root of the problem lies in how the SSL certificates and keys are being applied to the https.createServer method. Below is a breakdown of the steps to set it up correctly.
Step 1: Setting Up Certificates
Ensure you have the paths for your SSL certificates (private key, certificate, CA chain) correctly configured. These will be used to establish trust for secure connections.
Step 2: Modify the HTTPS Server Creation
Rather than using the output of tls.createSecureContext directly within https.createServer, you will provide the same options that createSecureContext accepts. This resolves compatibility issues.
Here's how your server setup code should look:
[[See Video to Reveal this Text or Code Snippet]]
Step 3: Verifying the Server Response
After making these changes, restart your server and try connecting using curl again. If everything works correctly, you should see a successful response without the handshake errors.
Conclusion
In summary, setting up an HTTPS server with Node.js requires careful attention to how SSL certificates and the server are configured. By ensuring the correct context options are passed to https.createServer, many handshake issues can be addressed. Remember to always ensure your client supports the same SSL/TLS versions as your server to avoid further complications.
By following these guidelines, you can efficiently resolve the curl cannot handshake issues and ensure secure communication in your Node.js applications. Happy coding!
On this page of the site you can watch the video online Resolving the curl cannot handshake Issue with Node.js HTTPS Server with a duration of hours minute second in good quality, which was uploaded by the user vlogize 17 April 2025, share the link with friends and acquaintances, this video has already been watched 16 times on youtube and it was liked by like viewers. Enjoy your viewing!