如何保护 EasyNetQ 和 c# 的 RabbitMQ 连接字符串?
How to secure RabbitMQ connection string for EasyNetQ and c#?
我需要从配置文件中读取连接字符串,但我不喜欢以明文形式保存密码的想法
RabbitHutch.CreateBus("host=MYHOST;username=MYUSER;password=MYPWD", sr => sr.Register<IEasyNetQLogger>(_ => new RabbitMQLogger()))
最佳做法是什么?问题不仅在于如何保护 strings/settings,还在于如何保护 RabbitMQ 连接详细信息。
我大概找到答案了
public static IBus CreateMessageBus()
{
var connectionString = ConfigurationManager.ConnectionStrings["easynetq"];
if (connectionString == null || connectionString.ConnectionString == string.Empty)
{
throw new VaultServiceException("easynetq connection string is missing or empty");
}
return RabbitHutch.CreateBus(connectionString.ConnectionString);
}
我需要从配置文件中读取连接字符串,但我不喜欢以明文形式保存密码的想法
RabbitHutch.CreateBus("host=MYHOST;username=MYUSER;password=MYPWD", sr => sr.Register<IEasyNetQLogger>(_ => new RabbitMQLogger()))
最佳做法是什么?问题不仅在于如何保护 strings/settings,还在于如何保护 RabbitMQ 连接详细信息。
我大概找到答案了
public static IBus CreateMessageBus()
{
var connectionString = ConfigurationManager.ConnectionStrings["easynetq"];
if (connectionString == null || connectionString.ConnectionString == string.Empty)
{
throw new VaultServiceException("easynetq connection string is missing or empty");
}
return RabbitHutch.CreateBus(connectionString.ConnectionString);
}