Troubleshooting the error message: "error:0308010c:digital envelope routines::unsupported"

Whenever you're working with Node.js apps, you might run into an error message that's a pretty common occurence, which is "error:0308010c:digital envelope routines::unsupported".

This often indicates that you have an issue with your SSL/TLS configuration and it typically arises whenever a cryptographic algorithm or protocol you use for encryption is unsupported.

Error:0308010c:digital envelope routines::unsupported

If you've already encountered the error, let's explore a few solutions to help you resolve the error and get you Node.js apps up and running in no time!

Solution #1 - Update Node.js and OpenSSL

It's crucial to keep your Node.js version up to date in order to ensure compatibility with the latest encryption algorithms and protocols. Also, updating OpenSSL, which is the underlying library that handles SSL/TLS, is just as important. By upgrading both Node.js and OpenSSL to their latest stable versions, you'll resolve any known issues and ensure the support of modern encryption methods.

Solution 2: Specify the TLS Version

In some cases, if you explicitly specify a TLS version in your Node.js application, that can help overcome the "unsupported" error. You can easily do this this by setting the secureProtocol option when making HTTPS requests or creating an HTTPS server. For example:

const https = require('https');
const options = {
  secureProtocol: 'TLSv1_2_method' // Specify the TLS version here
};

https.get(url, options, (res) => {
  // Handle the response
});

You should experiment with different TLS versions (TLSv1, TLSv1_1, TLSv1_2, etc.) to find the one that works best for your specific app.

Solution 3: Check Your System's OpenSSL Version

It's crucial to verify the version of OpenSSL installed on your system, as Node.js relies on it for SSL/TLS functionality. Since it's also possible that multiple versions of OpenSSL are installed simultaneously, that may lead to incompatibilities. To determine the OpenSSL version, use the below command:

openssl version

If you're running multiple versions, you just might need to update your system's environment variables or path to ensure that the correct version is being used by Node.js.

Solution 4: Reinstall Node.js Modules

In some particular cases, conflicts or issues with the installed Node.js modules can trigger the same "Error:0308010c:digital envelope routines::unsupported" message. Reinstalling the modules may resolve the problem.

You can start by deleting the node_modules directory within your project and then run npm install to reinstall the dependencies. This process ensures a clean installation of the modules and can repair any potential conflicts.

Solution 5: Disable Specific SSL/TLS Options

As a last resort, if you're running into such an issue that none of the previous solutions work, you can try disabling specific SSL/TLS options that might be causing the error.

For example, you can disable some cipher suites or enable only specific ones. However, please be CAREFUL when tampering with security-related options, as it could compromise the overall security of your apps.

Conclusion

While running into the "error:0308010c:digital envelope routines::unsupported" Node.js message can be frustrating, with the right troubleshooting steps, it can be resolved decently easy.

By updating Node.js and OpenSSL, specifying the TLS version, checking the system's OpenSSL version, reinstalling Node.js modules, or disabling specific SSL/TLS options, you can fix this issue and ensure your Node.js apps works seamlessly.

Do remember to consult the documentation of the specific modules or libraries you're using and seek assistance from the Node.js community if needed.

Dealing with bugs is 💩, but not with Jam.

Capture bugs fast, in a format that thousands of developers love.
Get Jam for free