Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upd nugets #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions samples/aws-sample/aws-sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@
<ItemGroup>
<ProjectReference Include="..\..\src\MQTTnet.Extensions.MultiCloud.AwsIoTClient\MQTTnet.Extensions.MultiCloud.AwsIoTClient.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="ridotest.cert.pem">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="ridotest.private.key">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions samples/aws-sample/ridotest.cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-----BEGIN CERTIFICATE-----
MIIDWjCCAkKgAwIBAgIVALqEepMGtu88f80cK6A5bQkwpJE4MA0GCSqGSIb3DQEB
CwUAME0xSzBJBgNVBAsMQkFtYXpvbiBXZWIgU2VydmljZXMgTz1BbWF6b24uY29t
IEluYy4gTD1TZWF0dGxlIFNUPVdhc2hpbmd0b24gQz1VUzAeFw0yNDA1MzAxNTQ5
MjFaFw00OTEyMzEyMzU5NTlaMB4xHDAaBgNVBAMME0FXUyBJb1QgQ2VydGlmaWNh
dGUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDEFFSVsoAYYEW06YZg
2DV71UaZFeJ15HIl7PSFKv5Lz5l7/qR0KufEhqNCJ8X7KbqGEe1feSM69Z1tUmXs
eruWXw+eGudhmVYogNY7GsIBBNMr8Lzi8RCaSBOViHBQXzxN8vp7u7wTPrOwWwTZ
NY0jHPT7kjcYDEHvVQt1HUB831Zc9lV7kSXXiUeiezJ3WtivQ77dtGZN4j6i6qcJ
kFYxf0svyAxMBOwsgUbosmTpGBa+CEv7QsT94uv2ZbkkpDp0h1VvwY+e+9v9xzJD
d2Tg5TcJFcqkpqhKtNVkmaqkoQN1AgYwcCieRV3s4Uxyp9ElkBw2aM3+65ae1GZs
wjqDAgMBAAGjYDBeMB8GA1UdIwQYMBaAFFtqSrj/zrgoKnCaKqjaJGRaEQNmMB0G
A1UdDgQWBBSCWAJITMHxqeZAx155EjdaeArhoTAMBgNVHRMBAf8EAjAAMA4GA1Ud
DwEB/wQEAwIHgDANBgkqhkiG9w0BAQsFAAOCAQEAGfaI6IqxCmwo+Y+7bxeQ/8FO
AmwCxluomreigTVMgdnhG5XtJiOAeuWJqorzwFouTs3a5XQQiTU3Tjqwzp4VwntM
k1GGOjkk0VxsuYqxQYmGjpLgZ6UWBI6HFXJgKiropUv+NPekxNa2wPuFvHkcYku4
F8aS+fuSZBAeL0uNixhgsO2ZzBPXFJTj28gcpYYOrevUAijoNsNLvLpx2XHwQSOT
uSiB0D4oD7JGHhXsgg7QMUvLnbt/Bdc9Cn1gBLYwShr6QhOjGxWxB8ReXVsQRiKb
G1ueKK1BUawFkR33LWsn5pUE2BekifAN+CcJoDtmBuf5E5rFdxeEgJ9Q+yEsfA==
-----END CERTIFICATE-----
2 changes: 1 addition & 1 deletion samples/memmon-protobuff/memmon-protobuff.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/memmon/memmon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.NET.Build.Containers" Version="0.3.2" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/pi-sense-device/pi-sense-device.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Iot.Device.Bindings" Version="2.2.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static async Task<IMqttClient> CreateFromConnectionSettingsAsync(Connecti
var dpsRes = await dpsClient.ProvisionDeviceIdentity();
cs.HostName = dpsRes.RegistrationState.AssignedHub;
cs.ClientId = dpsRes.RegistrationState.DeviceId;
await dpsMqtt.DisconnectAsync(new MqttClientDisconnectOptions() { Reason = MqttClientDisconnectReason.NormalDisconnection }, cancellationToken);
await dpsMqtt.DisconnectAsync(new MqttClientDisconnectOptions() { Reason = MqttClientDisconnectOptionsReason.NormalDisconnection }, cancellationToken);
}
var mqtt = new MqttFactory().CreateMqttClient(MqttNetTraceLogger.CreateTraceLogger()) as MqttClient;
MqttClientConnectResult connAck;
Expand Down
17 changes: 8 additions & 9 deletions src/MQTTnet.Extensions.MultiCloud/Connections/WithTlsSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ public static partial class MqttNetExtensions
{
public static MqttClientOptionsBuilder WithTlsSettings(this MqttClientOptionsBuilder builder, ConnectionSettings cs)
{
var tls = new MqttClientOptionsBuilderTlsParameters
{
UseTls = cs.UseTls
};

var tls = new MqttClientTlsOptionsBuilder();
if (cs.UseTls)
{
var certs = new List<X509Certificate2>();
Expand All @@ -34,15 +32,16 @@ public static MqttClientOptionsBuilder WithTlsSettings(this MqttClientOptionsBui
X509Certificate2Collection caCerts = new();
caCerts.ImportFromPemFile(cs.CaFile);
certs.AddRange(caCerts);
tls.CertificateValidationHandler = ea => X509ChainValidator.ValidateChain(ea.Certificate, cs.CaFile);
tls.WithCertificateValidationHandler(ea => X509ChainValidator.ValidateChain(ea.Certificate, cs.CaFile));

}
else
{
tls.CertificateValidationHandler += ea => X509ChainValidator.ValidateChain(ea.Certificate);
tls.WithCertificateValidationHandler(ea => X509ChainValidator.ValidateChain(ea.Certificate));
}
tls.Certificates = certs;
tls.IgnoreCertificateRevocationErrors = cs.DisableCrl;
builder.WithTls(tls);
tls.WithClientCertificates(certs);
tls.WithIgnoreCertificateRevocationErrors(cs.DisableCrl);
builder.WithTlsOptions(tls.Build());
}
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<ItemGroup>

<PackageReference Include="MQTTnet" Version="4.1.4.563" />
<PackageReference Include="MQTTnet" Version="4.3.6.1152" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task ConenctToAzPubSub()
};
var mqtt = await BrokerClientFactory.CreateFromConnectionSettingsAsync(cs);
Assert.True(mqtt.IsConnected);
await mqtt.DisconnectAsync(new Client.MqttClientDisconnectOptions() { Reason = Client.MqttClientDisconnectReason.NormalDisconnection});
await mqtt.DisconnectAsync(new Client.MqttClientDisconnectOptions() { Reason = Client.MqttClientDisconnectOptionsReason.NormalDisconnection});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task CheckComputedConnectionSettingsWhenUsingDPS()
Assert.Equal("tests.azure-devices.net", HubDpsFactory.ComputedSettings!.HostName);
await client.DisconnectAsync(
new MqttClientDisconnectOptionsBuilder()
.WithReason(MqttClientDisconnectReason.NormalDisconnection)
.WithReason(MqttClientDisconnectOptionsReason.NormalDisconnection)
.Build());
}

Expand All @@ -43,7 +43,7 @@ public async Task DpsCert()
Assert.Equal("tests.azure-devices.net", HubDpsFactory.ComputedSettings!.HostName);
await client.DisconnectAsync(
new MqttClientDisconnectOptionsBuilder()
.WithReason(MqttClientDisconnectReason.NormalDisconnection)
.WithReason(MqttClientDisconnectOptionsReason.NormalDisconnection)
.Build());
}

Expand All @@ -61,7 +61,7 @@ public async Task CheckComputedConnectionSettingsWhenNotUsingDPS()
Assert.Equal(Environment.GetEnvironmentVariable("TestHubName"), HubDpsFactory.ComputedSettings!.HostName);
await client.DisconnectAsync(
new MqttClientDisconnectOptionsBuilder()
.WithReason(MqttClientDisconnectReason.NormalDisconnection)
.WithReason(MqttClientDisconnectOptionsReason.NormalDisconnection)
.Build());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using MQTTnet.Diagnostics;
using MQTTnet.Packets;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -41,6 +42,7 @@ public MockMqttClient(string clientId)
public event Func<MqttClientDisconnectedEventArgs, Task> DisconnectedAsync;
public event Func<MqttApplicationMessageReceivedEventArgs, Task> ApplicationMessageReceivedAsync;
public event Func<InspectMqttPacketEventArgs, Task> InspectPackage;
public event Func<InspectMqttPacketEventArgs, Task> InspectPacketAsync;

//public event EventHandler<DisconnectEventArgs> OnMqttClientDisconnected;
//public event Func<MqttMessage, Task> OnMessage;
Expand Down Expand Up @@ -136,14 +138,15 @@ public Task<MqttClientSubscribeResult> SubscribeAsync(MqttClientSubscribeOptions
{
numSubscriptions++;
//options.TopicFilters.ForEach(t => Trace.TraceInformation(t.Topic));
var subAck = new MqttClientSubscribeResult();
List<MqttClientSubscribeResultItem> results = new();
var subAck = new MqttClientSubscribeResult(0, results, "", new List<MqttUserProperty>());
return Task.FromResult(subAck);
}

public Task<MqttClientUnsubscribeResult> UnsubscribeAsync(MqttClientUnsubscribeOptions options, CancellationToken cancellationToken = default)
{
numSubscriptions--;
return Task.FromResult(new MqttClientUnsubscribeResult());
return Task.FromResult(new MqttClientUnsubscribeResult(0, new List<MqttClientUnsubscribeResultItem>(), "", new List<MqttUserProperty>()));
}

public Task<MqttClientPublishResult> PublishAsync(MqttApplicationMessage applicationMessage, CancellationToken cancellationToken = default)
Expand All @@ -161,7 +164,7 @@ public Task<MqttClientPublishResult> PublishAsync(MqttApplicationMessage applica

topicRecceived = applicationMessage.Topic;
payloadReceived = jsonPayload!;// != null ? Encoding.UTF8.GetString(payload) : string.Empty;
return Task.FromResult(new MqttClientPublishResult());
return Task.FromResult(new MqttClientPublishResult(0, MqttClientPublishReasonCode.Success, "", new List<MqttUserProperty>()));
}

public void Dispose()
Expand Down
Loading