I'm working on a project and i need to open tls socket between NodeJS server and a device (http server embedded on electronic card, which operates on a PIC).
This device only support RC4-MD5 encryption algorithm but it's deprecated since Node 9 (I currently working on Node 14.17.5)
How can i implement RC4-MDR5 algorithm in NodeJS without downgrade my node version ?
My code actually:
const tls = require('tls');
let tlsOpts = { // TLS options
key: fs.readFileSync(path.resolve('dist/assets/cert/privkey.pem')),
cert: fs.readFileSync(path.resolve('dist/assets/cert/cert.pem')),
rejectUnauthorized: false,
ciphers: 'RC4-MD5' // This line throw error: SSL routines:SSL_CTX_set_cipher_list:no cipher match
};
this.server = tls.createServer(tlsOpts, async (socket) => { // Create server
socket.setEncoding('utf8');
this.events(socket); // Create event listeners (data, error, close, etc...)
}).listen(this.config.get('TCP_PORT'), () => {
this.logger.log('TCP server started (port '+this.config.get('TCP_PORT')+')'); // Log server start
});
Edit: To go further, how can i implement my own encryption algorithm and use it with the node tls package ?
Ex:
let tlsOpts = { // TLS options
key: fs.readFileSync(path.resolve('dist/assets/cert/privkey.pem')),
cert: fs.readFileSync(path.resolve('dist/assets/cert/cert.pem')),
rejectUnauthorized: false,
ciphers: 'My-Custom-Cipher' // Here use my custom algorithm
}
Note: I'm using NestJS framework, that why i have the syntax "this.[...]" in my code.
Thanks.