Azure / amqpnetlite

AMQP 1.0 .NET Library
Apache License 2.0
396 stars 141 forks source link

Invalid TLS version Azure Service Bus #517

Closed LukeRH closed 2 years ago

LukeRH commented 2 years ago

Hi, We are seeing the following exception message "Amqp.AmqpException: Invalid TLS version Azure Service Bus" when sending messages to a new Azure Service Bus with TLS 1.2 enforced as default. It looks like AMQPNetLite attempts to connect using TLS 1.0. Does AMQPNetLite support TLS 1.2?

To reproduce create a new AZ service bus with a topic and sub then run the Azure Service Bus topic example provided in the repo.

The workaround is to configure AZ service bus to accept connections using<TLS 1.2 as described here https://docs.microsoft.com/en-gb/azure/service-bus-messaging/transport-layer-security-enforce-minimum-version?WT.mc_id=Portal-Microsoft_Azure_ServiceBus but its not an ideal solution.

Thanks Luke

xinchen10 commented 2 years ago

Which .net runtime, .net framework, .net core or something else?

By default the library uses SslProtocols.Default which depends on the framework and version you use. To enforce TLS12, create a ConnectionFactory object and set ConnectionFactory.SSL.Protocols = SslProtocols.Tls12, and then use it to create a connection.

LukeRH commented 2 years ago

We are using .Net Framework 4.8

xinchen10 commented 2 years ago

Have you tried using SSL settings on ConnectionFactory? Does it work?

LukeRH commented 2 years ago

@xinchen10 Apologies for not replying sooner. Using the connection factory as suggested worked. ConnectionFactory connectionFactory = new ConnectionFactory(); connectionFactory.SSL.Protocols = System.Security.Authentication.SslProtocols.Tls12;

Thanks for your help Luke