Rabbit 的 SSL 支持.Net +视窗

发布于 2024-11-28 07:06:18 字数 2063 浏览 1 评论 0原文

我一直在尝试为我的rabbitMQ应用程序建立ssl支持,我遵循了rabbitmq文档链接 为了在我的rabbit.net应用程序中包含ssl支持,我已经能够成功创建用于ssl身份验证的证书,并为rabbit创建一个配置文件,并将其放置在rabbitMQ文件夹内的appdata文件夹中配置文件的代码:

[
 {rabbit, [
 {ssl_listeners, [5671]},
 {ssl_options, [{cacertfile,"C:\testca\cacert.cer"},
                {certfile,"C:\server\cert.pem"},
                {keyfile,"C:\server\key.pem"},
                {verify,verify_peer},
                {fail_if_no_peer_cert,false}]}
 ]}
 ]

我已经为发布者修改了我的rabbitMQ的c#代码,如下所示:

        ConnectionFactory factory = new ConnectionFactory();
        factory.Ssl.ServerName = System.Net.Dns.GetHostName();
        factory.Ssl.CertPath = "C:\\server\\keycert.p12";
        factory.Ssl.CertPassphrase = "password";
        factory.Ssl.Enabled = true;

但收到错误:BrokerUnreachableException已解除。

有什么提示或帮助吗?有什么遗漏请告诉我吗?

我使用 RabbitMQ:2.51。 厄兰:R14B01 操作系统:Windows 和 .net 客户端。

StackTrace:

Exception Message: None of the specified endpoints were reachable

Source: RabbitMQ.Client   

Stacktrace: at RabbitMQ.Client.ConnectionFactory.CreateConnection(Int32 maxRedirects)
               at RabbitMQ.Client.ConnectionFactory.CreateConnection()
               at RabbitProducer.Program.Main(String[] args) in C:\Users\pc 1\Documents\Visual Studio 2008\Projects\RabbitProducer\RabbitProducer\Program.cs:line 36

经纪人日志:

=INFO REPORT==== 9-Aug-2011::11:39:05 ===
Limiting to approx 924 file handles (829 sockets)

=INFO REPORT==== 9-Aug-2011::11:39:05 ===
Memory limit set to 804MB.

=INFO REPORT==== 9-Aug-2011::11:39:05 ===
msg_store_transient: using rabbit_msg_store_ets_index to provide index

=INFO REPORT==== 9-Aug-2011::11:39:05 ===
msg_store_persistent: using rabbit_msg_store_ets_index to provide index

=INFO REPORT==== 9-Aug-2011::11:39:05 ===
started TCP Listener on [::]:5672

=INFO REPORT==== 9-Aug-2011::11:39:05 ===
started TCP Listener on 0.0.0.0:5672

i have been trying to establish a ssl support for my rabbitMQ application, i have followed the rabbitmq documentation link to include ssl support in my .net application for rabbit, i have been able to successfully create certificates for the ssl authentication and created a config file for rabbit and placed it within the appdata folder inside rabbitMQ folder the code for the config file :

[
 {rabbit, [
 {ssl_listeners, [5671]},
 {ssl_options, [{cacertfile,"C:\testca\cacert.cer"},
                {certfile,"C:\server\cert.pem"},
                {keyfile,"C:\server\key.pem"},
                {verify,verify_peer},
                {fail_if_no_peer_cert,false}]}
 ]}
 ]

i have modified my c# code of rabbitMQ like this for the publisher:

        ConnectionFactory factory = new ConnectionFactory();
        factory.Ssl.ServerName = System.Net.Dns.GetHostName();
        factory.Ssl.CertPath = "C:\\server\\keycert.p12";
        factory.Ssl.CertPassphrase = "password";
        factory.Ssl.Enabled = true;

but am getting an error : BrokerUnreachableException was unhadled.

any tips or help? any minute thing am missing let me know ?

am using RabbitMQ:2.51.
Erlang: R14B01
OS: Windows and on .net client.

StackTrace:

Exception Message: None of the specified endpoints were reachable

Source: RabbitMQ.Client   

Stacktrace: at RabbitMQ.Client.ConnectionFactory.CreateConnection(Int32 maxRedirects)
               at RabbitMQ.Client.ConnectionFactory.CreateConnection()
               at RabbitProducer.Program.Main(String[] args) in C:\Users\pc 1\Documents\Visual Studio 2008\Projects\RabbitProducer\RabbitProducer\Program.cs:line 36

Broker Log:

=INFO REPORT==== 9-Aug-2011::11:39:05 ===
Limiting to approx 924 file handles (829 sockets)

=INFO REPORT==== 9-Aug-2011::11:39:05 ===
Memory limit set to 804MB.

=INFO REPORT==== 9-Aug-2011::11:39:05 ===
msg_store_transient: using rabbit_msg_store_ets_index to provide index

=INFO REPORT==== 9-Aug-2011::11:39:05 ===
msg_store_persistent: using rabbit_msg_store_ets_index to provide index

=INFO REPORT==== 9-Aug-2011::11:39:05 ===
started TCP Listener on [::]:5672

=INFO REPORT==== 9-Aug-2011::11:39:05 ===
started TCP Listener on 0.0.0.0:5672

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情话难免假 2024-12-05 07:06:18

当客户端无法连接到代理时,会发生BrokerUnreachableException。发生这种情况的原因有多种:代理未运行、Windows 防火墙阻止端口 5671、连接两端未正确安装证书。

调试:

  • 代理是否在监听 5671?检查日志文件中提及 ssl 侦听器的条目。它应该看起来像:

=信息报告==== 2011 年 8 月 8 日::11:51:47 ===
在 0.0.0.0:5671 上启动 SSL 侦听器

如果该条目不在日志文件中,请尝试通过 Program Files\RabbitMQ Server\rabbitmq-server 中的 rabbitmq-server.bat 脚本运行rabbitmq -xxx\sbin\,并检查横幅下的“config file: ...”条目是否设置为您的配置文件。 (none) 表示代理无法找到该文件。

一旦您知道正在读取配置文件,请确保您拥有正确的设置,如 中详细说明的RabbitMQ SSL 指南

  • 客户端是否已连接? (暂时忽略 ssl)以下是失败的 SSL 连接的样子:

=信息报告==== 2011 年 8 月 8 日::11:54:54 ===
已接受来自 127.0.0.1:52110 的 0.0.0.0:5671 上的 TCP 连接

=信息报告==== 2011 年 8 月 8 日::11:54:54 ===
开始 TCP 连接 <0.477.0>来自 127.0.0.1:52110

...

=错误报告==== 2011 年 8 月 8 日::11:54:55 ===
TCP 连接<0.477.0> 出现错误:{ssl_upgrade_error,"意外消息"}

=信息报告==== 2011 年 8 月 8 日::11:54:55 ===
关闭 TCP 连接 <0.477.0>

如果日志中没有此内容,则说明是防火墙问题。

  • 这是 Windows XP 吗?如果是这样,祝你好运,我们在其上运行 SSL 时遇到了问题。在许多情况下,Microsoft 有缺陷的 .NET 实现会阻止您从文件加载证书。

  • 如果是其他内容,请发布完整 .NET 堆栈跟踪、相关代理日志条目(“启动 TCP 连接”和“关闭 TCP 连接”之间的所有内容)以及配置文件.

  • 如果没有其他办法,请尝试RabbitMQ Discuss邮件列表。开发人员强调回答所有提出的问题。

BrokerUnreachableException occurs when the client cannot connect to the broker. This can occur for a number of reasons: broker not running, Windows Firewall is blocking port 5671, certificates were not installed properly on either side of the connection.

To debug:

  • Is the broker listening on 5671? Check the log file for the entry mentioning ssl listeners. It should look like:

=INFO REPORT==== 8-Aug-2011::11:51:47 ===
started SSL Listener on 0.0.0.0:5671

If that entry is not in the log file, try running rabbitmq via the rabbitmq-server.bat script in Program Files\RabbitMQ Server\rabbitmq-server-x.x.x\sbin\, and check that the "config file: ..." entry under the banner is set to your config file. (none) means that the broker was unable to locate the file.

Once you know the config file is being read, make sure you have the right settings as detailed in the RabbitMQ SSL Guide.

  • Is the client connecting at all? (ignoring ssl for now) The following is what a failed SSL connection looks like:

=INFO REPORT==== 8-Aug-2011::11:54:54 ===
accepted TCP connection on 0.0.0.0:5671 from 127.0.0.1:52110

=INFO REPORT==== 8-Aug-2011::11:54:54 ===
starting TCP connection <0.477.0> from 127.0.0.1:52110

...

=ERROR REPORT==== 8-Aug-2011::11:54:55 ===
error on TCP connection <0.477.0>:{ssl_upgrade_error,"unexpected message"}

=INFO REPORT==== 8-Aug-2011::11:54:55 ===
closing TCP connection <0.477.0>

If this isn't in the log, then it's a firewall issue.

  • Is this Windows XP? If so, good luck, we've have problems running SSL on it. In many cases, Microsoft's buggy .NET implementation will prevent you from loading certificates from files.

  • If it's something else, please post both the full .NET stacktrace, the relevant broker log entries (everything between the "Starting TCP connection" and the "closing TCP connection") and the config file.

  • If nothing else works, try the RabbitMQ Discuss mailing list. The developers make a point of answering all questions asked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文