While I was working on my full-stack application, I came across this cryptographic error and when I searched for it on StackOverflow and ChatGPT, I got to know it arised due to changes in Node.js's handling of OpenSSL, affecting cryptographic operations,i.e., my application was attempting to use cryptographic algorithms or features that are no longer supported in the current OpenSSL version bundled with Node.js. So, the error actually came from the dependency I downloaded relying on an obsolete version of SSL.
Thereupon, to fix this error :
Initially, I tried deleting my node_modules folder (from the frontend
workspace/folder) and re-running npm install in order to reinstall
the dependencies. However, this did not solve the issue.Then, I now understood that I should be switching the deprecated
algorithm to legacy mode in order to solve the compatibility issues.
And, while surfing regarding the deprecated algorithms, it got me
reminded of the SHA-1 in PGP (Pretty Good Privacy) I learnt in the
prior semester in college, in Computer Networks. SHA-1 is a hashing
algorithm which has become a deprecated algorithm because of the
security issues.
And continuing with the topic, since my app was a non-critical application which required some backward compatibility too, I decided to continue with using the --openssl-legacy-provider flag for a temporary workaround, as this would help me learn more about the possible errors that might occur, know more about root causes and how to solve it, along with other various terms that I might possibly encounter during the process.
The --openssl-legacy-provider enables the use of legacy algorithms by instructing Node.js to utilize OpenSSL's legacy provider, thereby restoring support for such cryptographic functions.
So, in the terminal, i started with :
npm update
npm audit fix — force
Then, on the package.json file, I made the following changes :
BEFORE :
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
AFTER :
"scripts": {
"start": "react-scripts --openssl-legacy-provider start",
"build": "react-scripts --openssl-legacy-provider build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
Now, this finally solved the issue and I loved how I progressed learning about different things just by trying to resolve this issue myself, learnings about how npm functions in detail, how versions are managed, about the deprecated and legacy algorithms, etc.
Top comments (0)