Rabbit 的 SSL 支持.Net +视窗
我一直在尝试为我的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当客户端无法连接到代理时,会发生
BrokerUnreachableException
。发生这种情况的原因有多种:代理未运行、Windows 防火墙阻止端口 5671、连接两端未正确安装证书。调试:
如果该条目不在日志文件中,请尝试通过 Program Files\RabbitMQ Server\rabbitmq-server 中的
rabbitmq-server.bat
脚本运行rabbitmq -xxx\sbin\,并检查横幅下的“config file: ...”条目是否设置为您的配置文件。(none)
表示代理无法找到该文件。一旦您知道正在读取配置文件,请确保您拥有正确的设置,如 中详细说明的RabbitMQ SSL 指南。
如果日志中没有此内容,则说明是防火墙问题。
这是 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:
If that entry is not in the log file, try running rabbitmq via the
rabbitmq-server.bat
script inProgram 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.
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.