MBW.Tools.RabbitDump icon indicating copy to clipboard operation
MBW.Tools.RabbitDump copied to clipboard

SSL Support

Open GoodmanEScott opened this issue 2 years ago • 0 comments

When the RabbitMQ clustered is configured for TLS this tool is unable to connect and an exception is thrown:

Unhandled exception. RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable
 ---> System.IO.IOException: connection.start was never received, likely due to a network timeout
   at RabbitMQ.Client.Framing.Impl.Connection.StartAndTune()
   at RabbitMQ.Client.Framing.Impl.Connection.Open(Boolean insist)
   at RabbitMQ.Client.Framing.Impl.Connection..ctor(IConnectionFactory factory, Boolean insist, IFrameHandler frameHandler, String clientProvidedName)
   at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IFrameHandler fh)
   at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IEndpointResolver endpoints)
   at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
   --- End of inner exception stack trace ---
   at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
   at RabbitMQ.Client.ConnectionFactory.CreateConnection(String clientProvidedName)
   at RabbitMQ.Client.ConnectionFactory.CreateConnection()
   at MBW.Tools.RabbitDump.Movers.Amqp.UriConnectionFactory.CreateConnection() in /_/src/MBW.Tools.RabbitDump/Movers/Amqp/UriConnectionFactory.cs:line 33
   at MBW.Tools.RabbitDump.Movers.Amqp.AmqpSource..ctor(ArgumentsModel model, ILogger`1 logger) in /_/src/MBW.Tools.RabbitDump/Movers/Amqp/AmqpSource.cs:line 32
   <snip />
   at MBW.Tools.RabbitDump.Program.<>c__DisplayClass0_0.<Main>b__4() in /_/src/MBW.Tools.RabbitDump/Program.cs:line 88
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass143_0.<OnExecute>b__0(CancellationToken _)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at MBW.Tools.RabbitDump.Program.Main(String[] args) in /_/src/MBW.Tools.RabbitDump/Program.cs:line 95

When I set the SslOption on the ConnectionFactory within the URI ConnectionFactory then it works:

	var factory = new ConnectionFactory
	{
		HostName = uri.Host,
		Port = uri.IsDefaultPort ? 5672 : uri.Port,
		Ssl = new SslOption
		{
			Enabled = true,
			ServerName = uri.Host,
		},
		UserName = user,
		Password = password,
		VirtualHost = uri.AbsolutePath == "/" ? "/" : uri.AbsolutePath.Remove(0, 1),
		AutomaticRecoveryEnabled = true
	};

GoodmanEScott avatar Aug 14 '23 16:08 GoodmanEScott