Sending AMQP Telemetry to Azure Event Hub not using TLS encryption

ε祈祈猫儿з 提交于 2019-12-11 12:02:37

问题


Is it possible to send AMQP packets/telemetry to Azure Event Hub not using TLS encryption?

The reason I want to do this, is to see exactly what a non-encrypted AMQP packet looks like.

I have tried the following code (see amqpTransSetting.UseSslStreamSecurity = false, but it still encrypts the communication.

        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--;
            }

回答1:


SSL/TLS connection is mandatory for accessing to all entities in the Service Bus (queues, topics/subscriptions and event hubs). You can't connect without it.

Paolo.



来源:https://stackoverflow.com/questions/29665965/sending-amqp-telemetry-to-azure-event-hub-not-using-tls-encryption

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!