开发者

SSL Support for Rabbit + .Net + Windows

开发者 https://www.devze.com 2023-03-26 08:24 出处:网络
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

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 rab开发者_JS百科bitMQ 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消