示例#1
0
        protected Details(
            string iothubConnectionString,
            string eventhubCompatibleEndpointWithEntityPath,
            string deviceId,
            string certificateFileName,
            string edgeHostName,
            bool useWebSockets
            )
        {
            this.iothubConnectionString = iothubConnectionString;
            this.eventhubCompatibleEndpointWithEntityPath = eventhubCompatibleEndpointWithEntityPath;
            this.deviceId            = deviceId;
            this.certificateFileName = certificateFileName;
            this.edgeHostName        = edgeHostName;

            if (useWebSockets)
            {
                this.serviceClientTransportType  = ServiceClientTransportType.Amqp_WebSocket_Only;
                this.eventHubClientTransportType = EventHubClientTransportType.AmqpWebSockets;
                this.deviceClientTransportType   = DeviceClientTransportType.Mqtt_WebSocket_Only;
            }
            else
            {
                this.serviceClientTransportType  = ServiceClientTransportType.Amqp;
                this.eventHubClientTransportType = EventHubClientTransportType.Amqp;
                this.deviceClientTransportType   = DeviceClientTransportType.Mqtt;
            }
        }
示例#2
0
        protected Details(
            string iothubConnectionString,
            string eventhubCompatibleEndpointWithEntityPath,
            string deviceId,
            string trustedCACertificateFileName,
            string edgeHostName,
            bool useWebSockets,
            Option <DeviceCertificate> clientCertificatePaths,
            Option <IList <string> > thumbprintCertificatePaths)
        {
            this.iothubConnectionString = iothubConnectionString;
            this.eventhubCompatibleEndpointWithEntityPath = eventhubCompatibleEndpointWithEntityPath;
            this.deviceId = deviceId;
            this.trustedCACertificateFileName = trustedCACertificateFileName;
            this.edgeHostName = edgeHostName;
            (this.authType,
             this.clientCertificate,
             this.clientCertificateChain,
             this.thumbprints) = this.ObtainAuthDetails(clientCertificatePaths, thumbprintCertificatePaths);

            if (useWebSockets)
            {
                this.serviceClientTransportType  = ServiceClientTransportType.Amqp_WebSocket_Only;
                this.eventHubClientTransportType = EventHubClientTransportType.AmqpWebSockets;
                this.deviceTransportSettings     = new ITransportSettings[] { new MqttTransportSettings(DeviceClientTransportType.Mqtt_WebSocket_Only) };
            }
            else
            {
                this.serviceClientTransportType  = ServiceClientTransportType.Amqp;
                this.eventHubClientTransportType = EventHubClientTransportType.Amqp;
                this.deviceTransportSettings     = new ITransportSettings[] { new MqttTransportSettings(DeviceClientTransportType.Mqtt_Tcp_Only) };
            }
        }
示例#3
0
        protected Details(
            IBootstrapper bootstrapper,
            Option <RegistryCredentials> credentials,
            string iothubConnectionString,
            string eventhubCompatibleEndpointWithEntityPath,
            UpstreamProtocolType upstreamProtocol,
            Option <string> proxy,
            string imageTag,
            string deviceId,
            string hostname,
            Option <string> deploymentFileName,
            Option <string> twinTestFileName,
            string deviceCaCert,
            string deviceCaPk,
            string deviceCaCerts,
            bool optimizedForPerformance,
            bool initializeWithAgentArtifact,
            LogLevel runtimeLogLevel,
            bool cleanUpExistingDeviceOnSuccess,
            Option <DPSAttestation> dpsAttestation)
        {
            this.bootstrapper           = bootstrapper;
            this.credentials            = credentials;
            this.iothubConnectionString = iothubConnectionString;
            this.dpsAttestation         = dpsAttestation;
            this.eventhubCompatibleEndpointWithEntityPath = eventhubCompatibleEndpointWithEntityPath;

            switch (upstreamProtocol)
            {
            case UpstreamProtocolType.Amqp:
            case UpstreamProtocolType.Mqtt:
                this.serviceClientTransportType  = ServiceClientTransportType.Amqp;
                this.eventHubClientTransportType = EventHubClientTransportType.Amqp;
                break;

            case UpstreamProtocolType.AmqpWs:
            case UpstreamProtocolType.MqttWs:
                this.serviceClientTransportType  = ServiceClientTransportType.Amqp_WebSocket_Only;
                this.eventHubClientTransportType = EventHubClientTransportType.AmqpWebSockets;
                break;

            default:
                throw new Exception($"Unexpected upstream protocol type {upstreamProtocol}");
            }

            this.imageTag                       = imageTag;
            this.deviceId                       = deviceId;
            this.hostname                       = hostname;
            this.DeploymentFileName             = deploymentFileName;
            this.TwinTestFileName               = twinTestFileName;
            this.deviceCaCert                   = deviceCaCert;
            this.deviceCaPk                     = deviceCaPk;
            this.deviceCaCerts                  = deviceCaCerts;
            this.optimizedForPerformance        = optimizedForPerformance;
            this.initializeWithAgentArtifact    = initializeWithAgentArtifact;
            this.runtimeLogLevel                = runtimeLogLevel;
            this.cleanUpExistingDeviceOnSuccess = cleanUpExistingDeviceOnSuccess;
            this.proxy = proxy.Map(p => new WebProxy(p) as IWebProxy);
        }
示例#4
0
        protected Details(
            string iothubConnectionString,
            string eventhubCompatibleEndpointWithEntityPath,
            string deviceId,
            string trustedCACertificateFileName,
            string edgeHostName,
            string edgeDeviceId,
            bool useWebSockets,
            Option <DeviceCertificate> clientCertificatePaths,
            Option <IList <string> > thumbprintCertificatePaths)
        {
            this.iothubConnectionString = iothubConnectionString;
            this.eventhubCompatibleEndpointWithEntityPath = eventhubCompatibleEndpointWithEntityPath;
            this.deviceId = deviceId;
            this.trustedCACertificateFileName = trustedCACertificateFileName;
            this.edgeHostName = edgeHostName;
            if (!edgeDeviceId.IsNullOrWhiteSpace())
            {
                this.edgeDeviceId = Option.Some(edgeDeviceId);
            }

            (this.authType,
             this.clientCertificate,
             this.clientCertificateChain,
             this.thumbprints) = ObtainAuthDetails(clientCertificatePaths, thumbprintCertificatePaths);

            if (useWebSockets)
            {
                this.serviceClientTransportType  = ServiceClientTransportType.Amqp_WebSocket_Only;
                this.eventHubClientTransportType = EventHubClientTransportType.AmqpWebSockets;
                this.deviceTransportSettings     = new ITransportSettings[] { new MqttTransportSettings(DeviceClientTransportType.Mqtt_WebSocket_Only) };
            }
            else
            {
                this.serviceClientTransportType  = ServiceClientTransportType.Amqp;
                this.eventHubClientTransportType = EventHubClientTransportType.Amqp;
                this.deviceTransportSettings     = new ITransportSettings[] { new MqttTransportSettings(DeviceClientTransportType.Mqtt_Tcp_Only) };
            }

            Console.WriteLine(
                $"Leaf Device Client: \n"
                + $"\t[authType={this.authType}] \n"
                + $"\t[clientCertificate subject name={this.clientCertificate.Match(c => c.SubjectName.ToString(), () => string.Empty)}] \n"
                + $"\t[clientCertificateChain count={this.clientCertificateChain.Match(c => c.Count(), () => 0)}] \n"
                + $"\t[service client transport type={this.serviceClientTransportType}]\n"
                + $"\t[event hub client transport type={this.eventHubClientTransportType}]\n"
                + $"\t[device transport type={this.deviceTransportSettings.First().GetTransportType()}]");
        }