问题
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