I hereby claim:
- I am ridomin on github.
- I am ridomin (https://keybase.io/ridomin) on keybase.
- I have a public key ASBq7sRbyP_O_D92H5hKcAmKqN26JnhtCR-etmECgo4YsAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| // @ts-check | |
| const filterMap = (om, dtmi, kind) => Object.entries(om).filter(e => e[1].EntityKind === kind && e[1].ChildOf === dtmi).map(e => e[1]) | |
| export class InterfaceInfo { | |
| constructor (om, dtmi) { | |
| /** @type import("./DtdlOM").DtdlObjectModel */ | |
| this.om = om | |
| this.telemetries = filterMap(om, dtmi, "Telemetry") | |
| this.properties = filterMap(om, dtmi, "Property") | |
| this.commands = filterMap(om, dtmi, "Command") | |
| this.components = filterMap(om, dtmi, "Component") |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| var number = 45673; | |
| var multiples = Multiples(number); | |
| Console.WriteLine($"{number} is " + | |
| $"{(multiples.Any() ? "not " : "")}prime"); |
| $root = gci "cert:\CurrentUser\my\<ca-thumbprint>" | |
| Write-Host "Creating a Leaf Certificate chained to root:" | |
| Write-Host " Root Subject:" $root.Subject.Substring(3) | |
| Write-Host " Root Thumprint:" $root.Thumbprint | |
| $certName = Read-Host "Device ID?" | |
| $keyPwd = Read-Host "Key Password?" -AsSecureString | |
| $cert = New-SelfSignedCertificate ` |
| -----BEGIN CERTIFICATE----- | |
| MIICyzCCAbOgAwIBAgIUPh/CfFW2v2IAAHPPRoOn2DTd86UwDQYJKoZIhvcNAQEL | |
| BQAwFTETMBEGA1UEAwwKcmlkb2NhZnkyMjAeFw0yMTA5MjEwNDE0NDdaFw0yMzAy | |
| MDMwNDE0NDdaMBUxEzARBgNVBAMMCnJpZG9jYWZ5MjIwggEiMA0GCSqGSIb3DQEB | |
| AQUAA4IBDwAwggEKAoIBAQCrXflb9C84jYfU6VEK0gwv3ejvkv7dFkxhu1SxU71x | |
| nabSen8zhswq1o5L2ogR97eInZXV76AXqvJ51gaF/yCIktFsIIALKWL2Lmihu79P | |
| UAY2+5lbFji+W95yPhta8EPywjm7OIUQvj9cuHxy1FLvY1bDE07axRkALgmptZfX | |
| EH8VSWwBQaJKw7Tlo5+27CyvraY2+Q/kOU9ibBfGhEaeK/VG9RkwXQlUmxg0IOQ3 | |
| uJj7E5K1T7nJBr/f1LR+fAqt/6g5Bv096mrYG8LpFwK6sDQPz8/mYzPe98zpK1KP | |
| 6VEYOxf+s6n3VJCVY/86UyaJvWawe59yRYmNXH8e99HJAgMBAAGjEzARMA8GA1Ud |
| namespace DeviceHttpDemo; | |
| public class Config | |
| { | |
| public string host = ""; | |
| public string did = ""; | |
| public string key = ""; | |
| } | |
| internal class SasAuth |
| openapi: '3.0.2' | |
| info: | |
| title: MyIoTAPI | |
| version: '1.0' | |
| paths: | |
| /readDeviceInfo: | |
| get: | |
| operationId: "readDeviceInfo" |
| using MQTTnet.Client.Options; | |
| using System.Text; | |
| namespace demistify_iothub | |
| { | |
| public static class MqttNetExtensions | |
| { | |
| public static MqttClientOptionsBuilder WithAzureIoTHubCredentialsSas(this MqttClientOptionsBuilder builder, string hostName, string deviceId, string sasKey, string modelId = "", int sasMinutes = 60) | |
| { | |
| (string username, string password) = SasAuth.GenerateHubSasCredentials(hostName, deviceId, sasKey, modelId, sasMinutes); |
| public static MqttClientOptionsBuilder WithAzureIoTHubCredentialsSas(this MqttClientOptionsBuilder builder, string hostName, string deviceId, string sasKey, string modelId, int sasMinutes = 60) | |
| { | |
| (string username, string password) = SasAuth.GenerateHubSasCredentials(hostName, deviceId, sasKey, modelId, sasMinutes); | |
| builder | |
| .WithTcpServer(hostName, 8883) | |
| .WithTls() | |
| .WithClientId($"{deviceId}") | |
| .WithCredentials(username, password); | |
| return builder; |
| namespace Rido.MqttCore | |
| { | |
| public class SasAuth | |
| { | |
| private const string apiversion_2020_09_30 = "2020-09-30"; | |
| public static string GetUserName(string hostName, string deviceId, string modelId = "") => | |
| $"{hostName}/{deviceId}/?api-version={apiversion_2020_09_30}&model-id={modelId}"; | |
| private static string Sign(string requestString, string key) | |
| { |