不使用 TLS 加密将 AMQP 遥测发送到 Azure 事件中心

Sending AMQP Telemetry to Azure Event Hub not using TLS encryption

是否可以不使用 TLS 加密将 AMQP packets/telemetry 发送到 Azure 事件中心?

我想这样做的原因是为了准确查看未加密的 AMQP 数据包是什么样子。

我试过下面的代码(参见amqpTransSetting.UseSslStreamSecurity = false,但它仍然加密通信。

        var amqpTransSetting = new AmqpTransportSettings();
        amqpTransSetting.UseSslStreamSecurity = false;

        var cs = @"Endpoint=sb://companyname-ns.servicebus.windows.net/;SharedAccessKeyName=EventHubPublisher;SharedAccessKey=84EHa5NNllnZBzH5ksogvNfhMWtIokdTdjxXXXXXXX=";

        var builder = new ServiceBusConnectionStringBuilder(cs)
                    {
                        TransportType = TransportType.Amqp,
                    };

        var client = EventHubClient.CreateFromConnectionString(builder.ToString(), "companyname-eh");

        int sentCount = sendCount;
        string infoText;

        for (int i = 0; i < sendCount; i++)
        {
            try
            {
                if (MessageType.Text == "Fake Sensor")
                {
                    infoText = "Sent using AMQP protocol";
                }
                else
                {
                    infoText = "Sent using AMQP protocol";
                }

                Random rnd = new Random();
                int intTemp = rnd.Next(15, 25);
                int intHum = rnd.Next(50, 80);

                var e = new Event
                {
                    MessageType = MessageType.Text,
                    Temp = intTemp,
                    Humidity = intHum,
                    Location = Location.Text,
                    Room = Room.Text,
                    Info = infoText
                };

                var serializedString = JsonConvert.SerializeObject(e);
                var data = new EventData(Encoding.UTF8.GetBytes(serializedString))
                {
                    PartitionKey = rnd.Next(6).ToString()
                };

                // Set user properties if needed
                data.Properties.Add("Type", "Telemetry_" + DateTime.Now.ToLongTimeString());



                await client.SendAsync(data).ConfigureAwait(false);
            }
            catch (Exception exp)
            {
                Console.WriteLine("Error on send: " + exp.Message);
                sentCount--;
            }

SSL/TLS 连接对于访问服务总线中的所有实体(队列、topics/subscriptions 和事件中心)是必需的。没有它你无法连接。

保罗.