sslasp.net-coremasstransitcloudamqp

Can't get SSL to work with MassTransit and cloudamqp


I've been struggling to figure out how I'm meant to configure MassTransit and our new dedicated cloudamqp instance to work with SSL (note:everything is working without SSL fine).

I tried adding the UseSsl line in the code below, which I found in some old documentation, but that didn't work:

var bus = Bus.Factory.CreateUsingRabbitMq(sbc =>
          {
              var host = sbc.Host(new Uri(messageBusConfiguration["Host"]), h =>
              {
                   h.Username(messageBusConfiguration["Username"]);
                   h.Password(messageBusConfiguration["Password"]);
                   h.UseSsl(s => {});
               });
            });

In cloudamqp I've set it to allow ampqs too and my services/APIs are setup and running in IIS using HTTPs without any issues.

I suspect I'm missing something fundamental here but I can't find any documentation on it.


Solution

  • This works for me, note that the port must be specified.

    var busControl = Bus.Factory.CreateUsingRabbitMq(x =>
    {
        var host = x.Host(new Uri("rabbitmq://wombat.rmq.cloudamqp.com:5671/your_vhost/"), h =>
        {
            h.Username("your_username");
            h.Password("your_password");
    
            h.UseSsl(s =>
            {
                s.Protocol = SslProtocols.Tls12;
            });
        });
    
        x.ReceiveEndpoint(host, "input_queue", e =>
        {
        });
    });
    
    await busControl.StartAsync(new CancellationTokenSource(TimeSpan.FromSeconds(30)).Token);
    
    await busControl.StopAsync();