Samson Olusegun
Samson Olusegun's Blog

Follow

Samson Olusegun's Blog

Follow

Solving OpenSSL legacy provider error while working with node versions >16

This issue is not a critical one but it won't allow your application to start anyways😐

Samson Olusegun's photo
Samson Olusegun
·Oct 28, 2022·

2 min read

Solving  OpenSSL legacy provider error while working with node versions >16

Hello reader, this is kind of a short read relating to an error I encountered while working on a demo.

I had just updated my local node version to v18 (well v19 is out in stable anyways) and there have been some changes as it relates to OpenSSL.

OpenSSL is a software library for applications that secure communications over computer networks against eavesdropping or the need to identify the party at the other end. It is widely used by Internet servers, including the majority of HTTPS websites. OpenSSL contains an open-source implementation of the SSL (Secure Socket Layer) and TLS (Transport Layer Security) protocols. The core library, written in the C programming language, implements basic cryptographic functions and provides various utility functions. en.wikipedia.org/wiki/OpenSSL

This issue is a result of one of the modules or packages I am using, which attempts to use an algorithm or key size which is no longer allowed by default with OpenSSL 3.0.

A new command-line option, --openssl-legacy-provider has been added to revert to the legacy provider as a temporary workaround for these tightened restrictions.

Depending on the framework, library or package your application might depend on. For me, this issue came up as a result of a package I am using bitcore-lib, used in processing bitcoin-related applications.

I developed mainly using windows+WSL and to solve this issue, you have to add this flag `--openssl-legacy-provider to your script tag in package.json but that is quite repetitive for projects that won't probably get to production anyways except official ones though.

To make this error vanish globally, add export NODE_OPTIONS=--openssl-legacy-provider to your ~/bashrc file (that's my default termin), you can do the same for any of the profiles your terminal depends on. This allows it to automatically set the node options globally in your terminal without having to add it to your project's package.json script every time.

image.png

Then your application can run without issues.

image.png

 
Share this