diff --git a/samples/README.md b/samples/README.md index d252474..7e3a386 100644 --- a/samples/README.md +++ b/samples/README.md @@ -2,7 +2,12 @@ This folder contains sample projects with devices that can be connected to multiple MQTT endpoints ->Note: All samples must be run with the `ConnectionStrings__cs` envvar, or as CLI argument `/ConnectionStrings:cs` . There are sample connection strings in the launchSettings.json.template to use as `dotnet run --launch-profile` +All samples must be run with the `ConnectionStrings__cs` envvar, or as CLI argument `/ConnectionStrings:cs` . + +There are sample connection strings in the `launchSettings.json.template` to use as `dotnet run --launch-profile`: + +- Rename the file to `launchSettings.json` +- Set device credentials (this file is .gitignored) ## memmon diff --git a/samples/memmon/Properties/launchSettings.json.template b/samples/memmon/Properties/launchSettings.json.template index 1100ee6..b4daca4 100644 --- a/samples/memmon/Properties/launchSettings.json.template +++ b/samples/memmon/Properties/launchSettings.json.template @@ -1,9 +1,15 @@ { "profiles": { - "mosquitto-localhost": { + "localhost": { "commandName": "Project", "environmentVariables": { - "ConnectionStrings__cs": "HostName=localhost;TcpPort=1883;DeviceId=memmon01;UserName=user;Password=password" + "ConnectionStrings__cs": "HostName=localhost;TcpPort=1883;UseTls=false;DeviceId=mqtt-device;UserName=user;Password=password" + } + }, + "localhost_tls": { + "commandName": "Project", + "environmentVariables": { + "ConnectionStrings__cs": "HostName=localhost;DeviceId=mqtt-device;UserName=user;Password=password;CaFile=localhost.pem" } }, "iothub": { @@ -25,22 +31,16 @@ "masterKey": "" } }, - "aws": { - "commandName": "Project", - "environmentVariables": { - "ConnectionStrings__cs": "HostName=.amazonaws.com;X509Key=cert.pem|cert.key" - } - }, "hub-x509": { "commandName": "Project", "environmentVariables": { - "ConnectionStrings__cs": "HostName=.azure-devices.net;X509Key=cert.pem|cert.key" + "ConnectionStrings__cs": "HostName=.azure-devices.net;X509Key=|" } }, - "broker-x509": { + "mosquitto_tls": { "commandName": "Project", "environmentVariables": { - "ConnectionStrings__cs": "HostName=testmosquitto.org;tcpport=8884;X509Key=ca-device.pem|ca-device.key;cafile=mosquitto.org.crt" + "ConnectionStrings__cs": "HostName=test.mosquitto.org;ClientId=mqtt-device;CaFile=test.mosquitto.org.crt" } } } diff --git a/samples/mqtt-device/Properties/launchSettings.json.template b/samples/mqtt-device/Properties/launchSettings.json.template index d230962..ef23014 100644 --- a/samples/mqtt-device/Properties/launchSettings.json.template +++ b/samples/mqtt-device/Properties/launchSettings.json.template @@ -1,9 +1,15 @@ { "profiles": { - "mosquitto-localhost": { + "localhost": { "commandName": "Project", "environmentVariables": { - "ConnectionStrings__cs": "HostName=localhost;TcpPort=1883;UseTls=false;DeviceId=sampledevice;UserName=user;Password=password;CaFile=localhost.ca.pem" + "ConnectionStrings__cs": "HostName=localhost;TcpPort=1883;UseTls=false;DeviceId=mqtt-device;UserName=user;Password=password" + } + }, + "localhost_tls": { + "commandName": "Project", + "environmentVariables": { + "ConnectionStrings__cs": "HostName=localhost;DeviceId=mqtt-device;UserName=user;Password=password;CaFile=localhost.pem" } }, "iothub": { @@ -25,22 +31,16 @@ "masterKey": "" } }, - "aws": { - "commandName": "Project", - "environmentVariables": { - "ConnectionStrings__cs": "HostName=.amazonaws.com;X509Key=cert.pem|cert.key" - } - }, "hub-x509": { "commandName": "Project", "environmentVariables": { - "ConnectionStrings__cs": "HostName=.azure-devices.net;X509Key=cert.pem|cert.key" + "ConnectionStrings__cs": "HostName=.azure-devices.net;X509Key=|" } }, - "broker-x509": { + "mosquitto_tls": { "commandName": "Project", "environmentVariables": { - "ConnectionStrings__cs": "HostName=testmosquitto.org;tcpport=8884;X509Key=ca-device.pem|ca-device.key;cafile=mosquitto.org.crt" + "ConnectionStrings__cs": "HostName=test.mosquitto.org;ClientId=mqtt-device;CaFile=test.mosquitto.org.crt" } } } diff --git a/samples/pi-sense-device/Properties/launchSettings.json.template b/samples/pi-sense-device/Properties/launchSettings.json.template index 1100ee6..b4daca4 100644 --- a/samples/pi-sense-device/Properties/launchSettings.json.template +++ b/samples/pi-sense-device/Properties/launchSettings.json.template @@ -1,9 +1,15 @@ { "profiles": { - "mosquitto-localhost": { + "localhost": { "commandName": "Project", "environmentVariables": { - "ConnectionStrings__cs": "HostName=localhost;TcpPort=1883;DeviceId=memmon01;UserName=user;Password=password" + "ConnectionStrings__cs": "HostName=localhost;TcpPort=1883;UseTls=false;DeviceId=mqtt-device;UserName=user;Password=password" + } + }, + "localhost_tls": { + "commandName": "Project", + "environmentVariables": { + "ConnectionStrings__cs": "HostName=localhost;DeviceId=mqtt-device;UserName=user;Password=password;CaFile=localhost.pem" } }, "iothub": { @@ -25,22 +31,16 @@ "masterKey": "" } }, - "aws": { - "commandName": "Project", - "environmentVariables": { - "ConnectionStrings__cs": "HostName=.amazonaws.com;X509Key=cert.pem|cert.key" - } - }, "hub-x509": { "commandName": "Project", "environmentVariables": { - "ConnectionStrings__cs": "HostName=.azure-devices.net;X509Key=cert.pem|cert.key" + "ConnectionStrings__cs": "HostName=.azure-devices.net;X509Key=|" } }, - "broker-x509": { + "mosquitto_tls": { "commandName": "Project", "environmentVariables": { - "ConnectionStrings__cs": "HostName=testmosquitto.org;tcpport=8884;X509Key=ca-device.pem|ca-device.key;cafile=mosquitto.org.crt" + "ConnectionStrings__cs": "HostName=test.mosquitto.org;ClientId=mqtt-device;CaFile=test.mosquitto.org.crt" } } } diff --git a/samples/pi-sense-device/mosquitto.org.crt b/samples/pi-sense-device/mosquitto.org.crt new file mode 100644 index 0000000..1294a2f --- /dev/null +++ b/samples/pi-sense-device/mosquitto.org.crt @@ -0,0 +1,24 @@ +-----BEGIN CERTIFICATE----- +MIIEAzCCAuugAwIBAgIUBY1hlCGvdj4NhBXkZ/uLUZNILAwwDQYJKoZIhvcNAQEL +BQAwgZAxCzAJBgNVBAYTAkdCMRcwFQYDVQQIDA5Vbml0ZWQgS2luZ2RvbTEOMAwG +A1UEBwwFRGVyYnkxEjAQBgNVBAoMCU1vc3F1aXR0bzELMAkGA1UECwwCQ0ExFjAU +BgNVBAMMDW1vc3F1aXR0by5vcmcxHzAdBgkqhkiG9w0BCQEW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