RabbitMQ .NET客户端无法使用TLS v1.2工作。

7

我正在尝试将RabbitMQ与TLS v1.2协议配合使用。同时在Java客户端和.NET Core客户端之间进行操作。目前Java客户端可以正常工作,但是.NET客户端存在问题。以下为我的工厂设置:

var factory = new ConnectionFactory
{
   HostName = hostName,
   VirtualHost = vHost,
   UserName = username,
   Password = password,
   Port = 5671,
   Ssl = {Enabled = true}
};

我收到了这个异常:System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Interop+OpenSsl+SslException: SSL Handshake failed with OpenSSL error - SSL_ERROR_SSL. ---> Interop+Crypto+OpenSslCryptographicException: error:1409442E:SSL routines:SSL3_READ_BYTES:tlsv1 alert protocol version
从异常消息的最后看来,TLS版本可能太旧了,但我安装了最新版本的RabbitMQ - 4.1.1。
在连接工厂类(ConnectionFactory)中深入研究了RabbitMQ源代码,但找不到任何与设置TLS版本有关的内容。在我的Java应用程序中,它的工作方式是:factory.useSslProtocol("TLSv1.2");
在另一个SO线程中看到,旧版本的Erlang可能是原因,但我安装了最新版本(8.1)。
请问接下来该在哪里查找?
更新:找到了设置TLS属性的方法: factory.Ssl.Version = SslProtocols.Tls12;
但现在我收到了System.Security.Authentication.AuthenticationException: The remote certificate is invalid异常。

你能分享一下你的配置文件吗?此外,你在CertMgr的受信任根证书文件夹中有证书颁发机构的证书吗? - brunch
1个回答

5

这对我起作用:

Ssl = new SslOption
{
    Version = SslProtocols.Tls12,
    Enabled = true,
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接