azure service bus
96 TopicsCommon causes of SSL/TLS connection issues and solutions
In the TLS connection common causes and troubleshooting guide (microsoft.com) and TLS connection common causes and troubleshooting guide (microsoft.com), the mechanism of establishing SSL/TLS and tools to troubleshoot SSL/TLS connection were introduced. In this article, I would like to introduce 3 common issues that may occur when establishing SSL/TLS connection and corresponding solutions for windows, Linux, .NET and Java. TLS version mismatch Cipher suite mismatch TLS certificate is not trusted TLS version mismatch Before we jump into solutions, let me introduce how TLS version is determined. As the dataflow introduced in the first session(https://techcommunity.microsoft.com/t5/azure-paas-blog/ssl-tls-connection-issue-troubleshooting-guide/ba-p/2108065), TLS connection is always started from client end, so it is client proposes a TLS version and server only finds out if server itself supports the client's TLS version. If the server supports the TLS version, then they can continue the conversation, if server does not support, the conversation is ended. Detection You may test with the tools introduced in this blog(TLS connection common causes and troubleshooting guide (microsoft.com)) to verify if TLS connection issue was caused by TLS version mismatch. If capturing network packet, you can also view TLS version specified in Client Hello. If connection terminated without Server Hello, it could be either TLS version mismatch or Ciphersuite mismatch. Solution Different types of clients have their own mechanism to determine TLS version. For example, Web browsers - IE, Edge, Chrome, Firefox have their own set of TLS versions. Applications have their own library to define TLS version. Operating system level like windows also supports to define TLS version. Web browser In the latest Edge and Chrome, TLS 1.0 and TLS 1.1 are deprecated. TLS 1.2 is the default TLS version for these 2 browsers. Below are the steps of setting TLS version in Internet Explorer and Firefox and are working in Window 10. Internet Explorer Search Internet Options Find the setting in the Advanced tab. Firefox Open Firefox, type about:config in the address bar. Type tls in the search bar, find the setting of security.tls.version.min and security.tls.version.max. The value is the range of supported tls version. 1 is for tls 1.0, 2 is for tls 1.1, 3 is for tls 1.2, 4 is for tls 1.3. Windows System Different windows OS versions have different default TLS versions. The default TLS version can be override by adding/editing DWORD registry values ‘Enabled’ and ‘DisabledByDefault’. These registry values are configured separately for the protocol client and server roles under the registry subkeys named using the following format: <SSL/TLS/DTLS> <major version number>.<minor version number><Client\Server> For example, below is the registry paths with version-specific subkeys: Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client For the details, please refer to Transport Layer Security (TLS) registry settings | Microsoft Learn. Application that running with .NET framework The application uses OS level configuration by default. For a quick test for http requests, you can add the below line to specify the TLS version in your application before TLS connection is established. To be on a safer end, you may define it in the beginning of the project. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Above can be used as a quick test to verify the problem, it is always recommended to follow below document for best practices. https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls Java Application For the Java application which uses Apache HttpClient to communicate with HTTP server, you may check link How to Set TLS Version in Apache HttpClient | Baeldung about how to set TLS version in code. Cipher suite mismatch Like TLS version mismatch, CipherSuite mismatch can also be tested with the tools that introduced in previous article. Detection In the network packet, the connection is terminated after Client Hello, so if you do not see a Server Hello packet, that indicates either TLS version mismatch or ciphersuite mismatch. If server is supported public access, you can also test using SSLLab(https://www.ssllabs.com/ssltest/analyze.html) to detect all supported CipherSuite. Solution From the process of establishing SSL/TLS connections, the server has final decision of choosing which CipherSuite in the communication. Different Windows OS versions support different TLS CipherSuite and priority order. For the supported CipherSuite, please refer to Cipher Suites in TLS/SSL (Schannel SSP) - Win32 apps | Microsoft Learn for details. If a service is hosted in Windows OS. the default order could be override by below group policy to affect the logic of choosing CipherSuite to communicate. The steps are working in the Windows Server 2019. Edit group policy -> Computer Configuration > Administrative Templates > Network > SSL Configuration Settings -> SSL Cipher Suite Order. Enable the configured with the priority list for all cipher suites you want. The CipherSuites can be manipulated by command as well. Please refer to TLS Module | Microsoft Learn for details. TLS certificate is not trusted Detection Access the url from web browser. It does not matter if the page can be loaded or not. Before loading anything from the remote server, web browser tries to establish TLS connection. If you see the error below returned, it means certificate is not trusted on current machine. Solution To resolve this issue, we need to add the CA certificate into client trusted root store. The CA certificate can be got from web browser. Click warning icon -> the warning of ‘isn’t secure’ in the browser. Click ‘show certificate’ button. Export the certificate. Import the exported crt file into client system. Windows Manage computer certificates. Trusted Root Certification Authorities -> Certificates -> All Tasks -> Import. Select the exported crt file with other default setting. Ubuntu Below command is used to check current trust CA information in the system. awk -v cmd='openssl x509 -noout -subject' ' /BEGIN/{close(cmd)};{print | cmd}' < /etc/ssl/certs/ca-certificates.crt If you did not see desired CA in the result, the commands below are used to add new CA certificates. $ sudo cp <exported crt file> /usr/local/share/ca-certificates $ sudo update-ca-certificates RedHat/CentOS Below command is used to check current trust CA information in the system. awk -v cmd='openssl x509 -noout -subject' ' /BEGIN/{close(cmd)};{print | cmd}' < /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem If you did not see desired CA in the result, the commands below are used to add new CA certificates. sudo cp <exported crt file> /etc/pki/ca-trust/source/anchors/ sudo update-ca-trust Java The JVM uses a trust store which contains certificates of well-known certification authorities. The trust store on the machine may not contain the new certificates that we recently started using. If this is the case, then the Java application would receive SSL failures when trying to access the storage endpoint. The errors would look like the following: Exception in thread "main" java.lang.RuntimeException: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at org.example.App.main(App.java:54) Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:130) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:371) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:314) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:309) Run the below command to import the crt file to JVM cert store. The command is working in the JDK 19.0.2. keytool -importcert -alias <alias> -keystore "<JAVA_HOME>/lib/security/cacerts" -storepass changeit -file <crt_file> Below command is used to export current certificates information in the JVM cert store. keytool -keystore " <JAVA_HOME>\lib\security\cacerts" -list -storepass changeit > cert.txt The certificate will be displayed in the cert.txt file if it was imported successfully.52KViews4likes0CommentsSSL/TLS connection issue troubleshooting guide
You may experience exceptions or errors when establishing TLS connections with Azure services. Exceptions are vary dramatically depending on the client and server types. A typical ones such as "Could not create SSL/TLS secure channel." "SSL Handshake Failed", etc. In this article we will discuss common causes of TLS related issue and troubleshooting steps.40KViews9likes1CommentIntroducing Local emulator for Azure Service Bus
Azure Service Bus is a fully managed enterprise message broker offering queues and publish-subscribe topics. It decouples applications and services, providing benefits like load-balancing across workers, safe data and control routing, and reliable transactional coordination. In response to your feedback, we are pleased to announce the introduction of a local emulator for Azure Service Bus. This emulator is intended to facilitate local development experience for Service Bus, allowing developers to develop and test their code against Azure Service Bus, in isolation away from cloud interference. Why emulator? Developers across the globe love emulators! While there are numerous compelling reasons to use emulators, here are just a few of those reasons to consider: Optimized development loop: The emulator speeds up dev/testing against Azure Service Bus. Pre-migration trial: Try Azure Service Bus using your existing AMQP applications before migrating to the cloud. Isolated environment: Use the emulator for dev/test setup without network latency or cloud resource constraints. Cost-efficient: The emulator is free and can be run on your local machine for dev/test scenarios. Note: The emulator is intended only for development and testing. It should not be used for production workloads. Official support is not provided, and any issues or suggestions should be reported via GitHub. Get started with Service Bus emulator The emulator is accessible as a Docker image on Microsoft Artifact Registry, and it is platform-independent, capable of running on Windows, macOS, and Linux. You can use our automated scripts from the Installer repository or initiate the emulator container using the docker compose command. The emulator is compatible with the latest service bus client SDKs and supports a wide variety of features within Azure Service Bus. For more details, please visit aka.ms/servicebusemulator Read more about Azure Service Bus: Introduction to Azure Service Bus, an enterprise message broker - Azure Service Bus | Microsoft Learn We appreciate your feedback and encourage you to share it with us. Please provide feedback or report any issues on our GitHub repository. Wishing you a smooth ride with the Service Bus emulator, making all your tests pass! 😊23KViews2likes4CommentsAzure Service Bus Premium: Large Message Support Generally Available
The "Large Message" feature of Azure Service Bus Premium is now generally available for production use. The feature is a new, per-entity message size limit configuration setting that can range from 1MByte to 100 MByte and defaults to 1 MByte. The generous 100 MByte limit enables a broad range of queue-based document transfer use-cases. The configurability of the limit ensures that your application is protected from messages that are larger than expected in existing buffers and by memory configurations and can be set to the exact limits you need.21KViews0likes0CommentsService Bus –Complete Message Asynchronously or Synchronously?
As we know there are two kinds of operations for program threads --- Asynchronous and Synchronous. These are the definitions we can get from internet. Asynchronous operation means the process operates independently of other processes. Synchronous operation means the process runs only as a resource or some other process being completed or handed off. However, whether it’s good to Receive Message Asynchronously on the Azure Service Bus? Pre-requirement Before we start, please read these documents. Service Bus asynchronous messaging and Azure Service Bus messaging receive mode From the above pre-requisites, we learn the following: Azure Service Bus support both Asynchronous messaging patterns and Synchronous messaging patterns. Applications typically use asynchronous messaging patterns to enable several communication scenarios. This test is archived based on Service Bus PeekLock Receive mode. Here is more background information about the principle for PeekLock receive mode. The principle for PeekLock Receive mode is that: Every time the Service Bus finds the next message to be consumed. Locks it to prevent other consumers from receiving it. Then, return the message to the application. There is a common exception for the Service Bus Lock expiration. This exception is because the message transaction time longer than Lock duration. It may be due to many reasons like Receive Application has high latency. This blog will also reproduce this Lock expired exception for Receive Messages Asynchronously and Synchronously. Let's do a test now!18KViews2likes0CommentsAzure Service bus || Peek/Delete scheduled message which has future enqueue time
Use Case: To peek/delete the scheduled messages from Azure service bus. Pre-Requisites: Azure Service bus Namespace Azure Service bus SAS connection string Console Application to peek/delete the scheduled message17KViews1like0CommentsAzure Service Bus | Receive Messages from DLQ for Queue/Subscription
Azure Service Bus queues and topic subscriptions provide a secondary subqueue, called a dead-letter queue(DLQ). The dead-letter queue need not to be explicitly created and can't be deleted or otherwise managed independent of the main entity. Azure Service Bus messaging overview - Azure Service Bus | Microsoft Docs Messages that can't be processed because of various reasons fall into DLQ. Below are few conditions where messages will fall into DLQ: 1. Not matching with the filter condition 2. TTL expired, header exceed 3. Quota exceed for header size 4. Max delivery count reached 5. Session enabled and sending messages without sessionID 6. Using more than 4 forward to Case: To receive DLQ messages from queue/subscription Pre-Requisites: 1. Service Bus namespace 2. Already created queue/subscription 3. Should have messages in DLQ either for queue/subscription 4. Service Bus Explorer We have multiple ways to receive messages from DLQ. Using Service Bus Explorer: Download the “Service Bus Explorer” from: https://github.com/paolosalvatori/ServiceBusExplorer Open service bus explorer and click File and connect it. From the drop down, select connection string and provide the connection string of the namespace level. Once it is successfully connected, you will see Service Bus Explorer shows the count of the DLQ message. In the below screenshot, there are 11 messages currently in the DLQ for the queue "ankitatest". To receive messages from DLQ through SB explorer, you need to click on that particular queue and then click on “Deadletter” tab then one dialogue box will pop up then you need to click on “Receive and Delete”. The default value is Top10 so top10 messages will be received from DLQ. The updated DLQ message count is now 1. Through C# Code: In the given screenshot, we have 12 messages in DLQ for queue and we wanted to receive them. I will run the below code which will receive the message from the mentioned queue. Once you run the code successfully, you will see the message ID in the console window as below. Now, check on SB explorer and you will see 1 message has been gone from DLQ. class Program { static void Main(string[] args) { RetrieveMessageFromDeadLetterForQueue(); RetrieveMessageFromDeadLetterForSubscription(); } public static void RetrieveMessageFromDeadLetterForQueue() { var receiverFactory = MessagingFactory.Create( "sb://<ServiceBusNamespaceName>.servicebus.windows.net/", new MessagingFactorySettings { TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "<NamespaceLevelKey>"), NetMessagingTransportSettings = { BatchFlushInterval = new TimeSpan(0, 0, 0) } }); string data = QueueClient.FormatDeadLetterPath("<QueueName>"); var receiver = receiverFactory.CreateMessageReceiver(data); receiver.OnMessageAsync( async message => { var body = message.GetBody<Stream>(); lock (Console.Out) { Console.WriteLine(message.MessageId); } await message.CompleteAsync(); }, new OnMessageOptions { AutoComplete = false, MaxConcurrentCalls = 1 }); } public static void RetrieveMessageFromDeadLetterForSubscription() { var receiverFactory = MessagingFactory.Create( "sb://<NS>.servicebus.windows.net/", new MessagingFactorySettings { TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "<NamespaceLevelSASKey>"), NetMessagingTransportSettings = { BatchFlushInterval = new TimeSpan(0, 0, 0) } }); string data = SubscriptionClient.FormatDeadLetterPath("<TopicName>", "<SubscriptionName>"); var receiver = receiverFactory.CreateMessageReceiver(data); receiver.OnMessageAsync( async message => { var body = message.GetBody<Stream>(); lock (Console.Out) { Console.WriteLine("Message ID :" + message.MessageId); } await message.CompleteAsync(); }, new OnMessageOptions { AutoComplete = false, MaxConcurrentCalls = 1 }); } }14KViews5likes0Comments