Skip to content

Commit

Permalink
Merge pull request #5 from Azure-Samples/main
Browse files Browse the repository at this point in the history
Merge Azure-Samples main into sseiber fork
  • Loading branch information
sseiber authored Dec 13, 2023
2 parents d0783af + d82044c commit 6c56a1b
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 67 deletions.
20 changes: 14 additions & 6 deletions Samples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Telemetry", "Telemetry", "{
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.Client.Extensions.Tests", "mqttclients\dotnet\MQTTnet.Client.Extensions.Tests\MQTTnet.Client.Extensions.Tests.csproj", "{C7DB8091-7451-4F96-9A7E-60405D86045E}"
EndProject

Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Alert", "Alert", "{6A8AEBE0-5277-4898-BB3A-42AA8D92D7AC}"
ProjectSection(SolutionItems) = preProject
scenarios\alert\README.md = scenarios\alert\README.md
Expand All @@ -29,7 +28,10 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "control_tower", "scenarios\alert\dotnet\control_tower\control_tower.csproj", "{9B4871A1-3D2F-4341-88FE-56C25C5DB78E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "alert_message", "scenarios\alert\dotnet\alert_message\alert_message.csproj", "{40F0F6D2-22B4-4BC0-A2AF-2FA20F25012E}"

EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "command_client", "scenarios\command\dotnet\command_client\command_client.csproj", "{8239001F-55C1-4ED4-A5D9-2D9C312792B6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "command_server", "scenarios\command\dotnet\command_server\command_server.csproj", "{02032E52-AF7C-4EA2-A6A9-18AF88346B1E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -61,7 +63,6 @@ Global
{C7DB8091-7451-4F96-9A7E-60405D86045E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7DB8091-7451-4F96-9A7E-60405D86045E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7DB8091-7451-4F96-9A7E-60405D86045E}.Release|Any CPU.Build.0 = Release|Any CPU

{E78483BF-5FF5-42DD-999A-30997CD5E079}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E78483BF-5FF5-42DD-999A-30997CD5E079}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E78483BF-5FF5-42DD-999A-30997CD5E079}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -74,7 +75,14 @@ Global
{40F0F6D2-22B4-4BC0-A2AF-2FA20F25012E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40F0F6D2-22B4-4BC0-A2AF-2FA20F25012E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40F0F6D2-22B4-4BC0-A2AF-2FA20F25012E}.Release|Any CPU.Build.0 = Release|Any CPU

{8239001F-55C1-4ED4-A5D9-2D9C312792B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8239001F-55C1-4ED4-A5D9-2D9C312792B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8239001F-55C1-4ED4-A5D9-2D9C312792B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8239001F-55C1-4ED4-A5D9-2D9C312792B6}.Release|Any CPU.Build.0 = Release|Any CPU
{02032E52-AF7C-4EA2-A6A9-18AF88346B1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02032E52-AF7C-4EA2-A6A9-18AF88346B1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02032E52-AF7C-4EA2-A6A9-18AF88346B1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02032E52-AF7C-4EA2-A6A9-18AF88346B1E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -83,11 +91,11 @@ Global
{199422AA-E99F-428A-AAAF-05A42E31B8AD} = {23D7EF17-B820-4C7E-9039-56A47FA35C55}
{63D62307-31E8-4D14-B92F-DEF195D697A3} = {67780A3E-3D40-4D1F-8F2D-BC15B2EE7FCB}
{48AF1BD5-B605-45E8-BB4E-9E015A0AAE29} = {67780A3E-3D40-4D1F-8F2D-BC15B2EE7FCB}

{E78483BF-5FF5-42DD-999A-30997CD5E079} = {6A8AEBE0-5277-4898-BB3A-42AA8D92D7AC}
{9B4871A1-3D2F-4341-88FE-56C25C5DB78E} = {6A8AEBE0-5277-4898-BB3A-42AA8D92D7AC}
{40F0F6D2-22B4-4BC0-A2AF-2FA20F25012E} = {6A8AEBE0-5277-4898-BB3A-42AA8D92D7AC}

{8239001F-55C1-4ED4-A5D9-2D9C312792B6} = {23D7EF17-B820-4C7E-9039-56A47FA35C55}
{02032E52-AF7C-4EA2-A6A9-18AF88346B1E} = {23D7EF17-B820-4C7E-9039-56A47FA35C55}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {07B8E195-2259-4EE7-B379-8A7CCC581E48}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MQTTnet" Version="4.3.1.873" />
<PackageReference Include="MQTTnet" Version="4.3.2.930" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ public static MqttClientOptionsBuilder WithTlsSettings(this MqttClientOptionsBui

if (!string.IsNullOrEmpty(cs.CaFile))
{
tlsParams.WithCertificateValidationHandler(ea => X509ChainValidator.ValidateChain(ea, cs.CaFile!));
X509Certificate2Collection chain = new();
chain.ImportFromPemFile(cs.CaFile);
tlsParams.WithTrustChain(chain);
tlsParams.WithRevocationMode(X509RevocationMode.NoCheck);
}

if (!string.IsNullOrEmpty(cs.CertFile) && !string.IsNullOrEmpty(cs.KeyFile))
Expand Down
51 changes: 0 additions & 51 deletions mqttclients/dotnet/MQTTnet.Client.Extensions/X509ChainValidator.cs

This file was deleted.

5 changes: 2 additions & 3 deletions mqttclients/python/connectionsettings/connection_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import sys
from typing_extensions import Required
from typing_extensions import TypedDict

from typing import Optional, Final
from typing import Optional, Final, List
import dotenv
import os

Expand All @@ -23,7 +22,7 @@ class ConnectionSettings(TypedDict, total=False):
MQTT_KEY_FILE_PASSWORD: str


mqtt_setting_names: Final[list[str]] = [
mqtt_setting_names: Final[List[str]] = [
'MQTT_HOST_NAME',
'MQTT_TCP_PORT',
'MQTT_USE_TLS',
Expand Down
4 changes: 3 additions & 1 deletion scenarios/command/python/command_invoker.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def create_mqtt_client(client_id, connection_settings):
password=connection_settings['MQTT_PASSWORD'] if 'MQTT_PASSWORD' in connection_settings else None
)
if connection_settings['MQTT_USE_TLS']:
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.minimum_version = ssl.TLSVersion.TLSv1_2
context.maximum_version = ssl.TLSVersion.TLSv1_3

if connection_settings['MQTT_CERT_FILE']:
context.load_cert_chain(
Expand Down
4 changes: 3 additions & 1 deletion scenarios/command/python/command_receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ def create_mqtt_client(client_id, connection_settings):
password=connection_settings['MQTT_PASSWORD'] if 'MQTT_PASSWORD' in connection_settings else None
)
if connection_settings['MQTT_USE_TLS']:
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.minimum_version = ssl.TLSVersion.TLSv1_2
context.maximum_version = ssl.TLSVersion.TLSv1_3

if connection_settings['MQTT_CERT_FILE']:
context.load_cert_chain(
Expand Down
4 changes: 3 additions & 1 deletion scenarios/getting_started/python/getting_started.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def create_mqtt_client(client_id, connection_settings):
password=connection_settings['MQTT_PASSWORD'] if 'MQTT_PASSWORD' in connection_settings else None
)
if connection_settings['MQTT_USE_TLS']:
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.minimum_version = ssl.TLSVersion.TLSv1_2
context.maximum_version = ssl.TLSVersion.TLSv1_3

if connection_settings['MQTT_CERT_FILE']:
context.load_cert_chain(
Expand Down
4 changes: 3 additions & 1 deletion scenarios/telemetry/python/telemetry_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def create_mqtt_client(client_id, connection_settings):
password=connection_settings['MQTT_PASSWORD'] if 'MQTT_PASSWORD' in connection_settings else None
)
if connection_settings['MQTT_USE_TLS']:
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.minimum_version = ssl.TLSVersion.TLSv1_2
context.maximum_version = ssl.TLSVersion.TLSv1_3

if connection_settings['MQTT_CERT_FILE']:
context.load_cert_chain(
Expand Down
4 changes: 3 additions & 1 deletion scenarios/telemetry/python/telemetry_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def create_mqtt_client(client_id, connection_settings):
password=connection_settings['MQTT_PASSWORD'] if 'MQTT_PASSWORD' in connection_settings else None
)
if connection_settings['MQTT_USE_TLS']:
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.minimum_version = ssl.TLSVersion.TLSv1_2
context.maximum_version = ssl.TLSVersion.TLSv1_3

if connection_settings['MQTT_CERT_FILE']:
context.load_cert_chain(
Expand Down

0 comments on commit 6c56a1b

Please sign in to comment.