How to set environment variables of nodejs?

1,508 views
Skip to first unread message

Alan Jhu

unread,
Dec 4, 2021, 11:03:45 AM12/4/21
to nw.js
I have to set the environment variables(NODE_OPTIONS=--openssl-legacy-provider)

Because Noejs v17 use OpenSSL v3.0 and it remove a lot of algorithm cause my program can't run correctly.

Thank you.

Roger Wang

unread,
Dec 12, 2021, 5:44:04 PM12/12/21
to Alan Jhu, nw.js
This looks like a bug. Could you provide a sample program so I can reproduce it?

Best regards,
Roger

--
You received this message because you are subscribed to the Google Groups "nw.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nwjs-general...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nwjs-general/9e60bd4f-b454-4c91-8421-63e4038aa561n%40googlegroups.com.

Alan Jhu

unread,
Dec 12, 2021, 9:27:57 PM12/12/21
to nw.js
The example is as follows

<!DOCTYPE html>
<html>
<head>
  <title>Example</title>
</head>
<body>
<script>
var cryptoNodejs = require('crypto');

var desKey = "A4ykcKJz";
var desIV = "zYt6D5TU";
var encryptedMessage = "PL9ulr7SG8s=";

var decipher = cryptoNodejs.createDecipheriv("des", desKey, desIV);
decipher.setAutoPadding(true);

var decryptedMessage = decipher.update(encryptedMessage, 'base64', 'utf8');
decryptedMessage += decipher.final('utf8');

document.write('Decrypted message is ', decryptedMessage);
</script>
</body>
</html>


In 0.58.0, the window will show "Decrypted message is Hello", but 0.59.0 will show as follows error message in console:

Uncaught Error: error:0308010C:digital envelope routines::unsupported
    at Decipheriv.createCipherBase (node:internal/crypto/cipher:116:19)
    at Decipheriv.createCipherWithIV (node:internal/crypto/cipher:135:3)
    at new Decipheriv (node:internal/crypto/cipher:289:3)
    at Object.createDecipheriv (node:crypto:146:10)
    at chrome-extension://nacjpihodniapipnjlbloghmhecglemm/index.htm:14:29


Because OpenSSL v3.0 remove the des algorithm, the nodejs can set the environment variables(NODE_OPTIONS=--openssl-legacy-provider) to downward compatible.

So my question is how to set the environment variables of nodejs in nwjs?

Thanks.
wen...@gmail.com 在 2021年12月13日 星期一上午6:44:04 [UTC+8] 的信中寫道:
Reply all
Reply to author
Forward
0 new messages