使用 ServiceStack.Redis 连接到 TSL Redis Cloud
Connecting to TSL Redis Cloud using ServiceStack.Redis
我正在尝试使用 ServiceStack.Redis 连接到使用 SSL 证书的基于云的 Redis 实例。 ServiceStack 文档提供了有关如何使用 SSL 连接到基于 Azure 的 Redis 的信息,但没有关于如何连接到非 Azure Redis 实例的信息或示例。
我有 pem、crt 和密钥文件,但我对它们所做的任何操作似乎都没有真正将它们传递给服务。我在 connectionstring 中设置了 ssl=true&sslprotocols=tls12 这似乎是第一步,但除此之外我不确定我应该做什么才能正确地通过证书进行验证
编辑:当前代码
RedisConfig.CertificateSelectionCallback = BuildCertificateSelectionCallback;
RedisConfig.CertificateValidationCallback = Config_CertificateValidation;
var hosts = redCon.Split(',');
var sentinel = new RedisSentinel(hosts, masterName)
{
RedisManagerFactory = CreateRedisManager,
.....
};
container.Register(c => sentinel.Start());
private static X509Certificate BuildCertificateSelectionCallback(object sender,string targetHost,X509CertificateCollection, X509Certificate remoteCertificate, string[] acceptableIssuers)
{
return new X509Certificate(@"[filepath]\rl.pfx");
}
private static bool Config_CertificateValidation(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
//Validation not fully fleshed out yet
if(sslPolicyErrors == SslPolicyErrors.None;)
{
return true;
}
return false;
}
ServiceStack.Redis使用.NET的SslStream to establish its SSL connection where you can configure its RemoteCertificateValidationCallback验证是否接受指定的证书进行身份验证:
RedisConfig.CertificateValidationCallback = (object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors) => {
//...
};
还有一个 LocalCertificateSelectionCallback 到 select 用于身份验证的本地 SSL 证书:
RedisConfig.CertificateSelectionCallback = (object sender,
string targetHost,
X509CertificateCollection localCertificates,
X509Certificate remoteCertificate,
string[] acceptableIssuers) => {
//...
}
我正在尝试使用 ServiceStack.Redis 连接到使用 SSL 证书的基于云的 Redis 实例。 ServiceStack 文档提供了有关如何使用 SSL 连接到基于 Azure 的 Redis 的信息,但没有关于如何连接到非 Azure Redis 实例的信息或示例。
我有 pem、crt 和密钥文件,但我对它们所做的任何操作似乎都没有真正将它们传递给服务。我在 connectionstring 中设置了 ssl=true&sslprotocols=tls12 这似乎是第一步,但除此之外我不确定我应该做什么才能正确地通过证书进行验证
编辑:当前代码
RedisConfig.CertificateSelectionCallback = BuildCertificateSelectionCallback;
RedisConfig.CertificateValidationCallback = Config_CertificateValidation;
var hosts = redCon.Split(',');
var sentinel = new RedisSentinel(hosts, masterName)
{
RedisManagerFactory = CreateRedisManager,
.....
};
container.Register(c => sentinel.Start());
private static X509Certificate BuildCertificateSelectionCallback(object sender,string targetHost,X509CertificateCollection, X509Certificate remoteCertificate, string[] acceptableIssuers)
{
return new X509Certificate(@"[filepath]\rl.pfx");
}
private static bool Config_CertificateValidation(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
//Validation not fully fleshed out yet
if(sslPolicyErrors == SslPolicyErrors.None;)
{
return true;
}
return false;
}
ServiceStack.Redis使用.NET的SslStream to establish its SSL connection where you can configure its RemoteCertificateValidationCallback验证是否接受指定的证书进行身份验证:
RedisConfig.CertificateValidationCallback = (object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors) => {
//...
};
还有一个 LocalCertificateSelectionCallback 到 select 用于身份验证的本地 SSL 证书:
RedisConfig.CertificateSelectionCallback = (object sender,
string targetHost,
X509CertificateCollection localCertificates,
X509Certificate remoteCertificate,
string[] acceptableIssuers) => {
//...
}