小编典典

保护节点Redis

redis

我正在尝试保护Node Redis
IPC服务器使用私钥/公钥。我遵循了本教程该教程stunnel将Redis 使用的隧道包装在SSL层下。

该示例不是针对Node的,但是它确实确保了连接的安全,并且只有在配置文件中包含证书的情况下,我才能连接到服务器,否则将重置连接。

但是,我无法使用NodeJS复制它。在服务器计算机上,我有:

var redis = require('redis'); 
var client = redis.createClient();

client.auth('myPassword');
client.publish('instances', 'start');

在我的客户端计算机上,我有:

var redis = require('redis');
var client = redis.createClient();

client.auth('myPassword');
client.subscribe('instances');
client.on('message', function (channel, message) {
  console.log("Got message " + message + " from channel " + channel);
})

但是,这两个设备会交流我是否在stunnel配置文件中包括了证书。如何确保此连接的安全?

干杯


阅读 307

收藏
2020-06-20

共1个答案

小编典典

您可以通过在创建客户端时像这样传递tls配置来完成此操作

var redis = require("redis");

var client = redis.createClient(6380,'location.of.server', {auth_pass: 'password', tls: {servername: 'location.of.server'}});
2020-06-20