public async Task X509ProvisionEdgeAsync() { await Profiler.Run( async() => { using (var cts = new CancellationTokenSource(Context.Current.SetupTimeout)) { CancellationToken token = cts.Token; DateTime startTime = DateTime.Now; string deviceId = DeviceId.Current.Generate(); (X509Thumbprint thumbprint, string certPath, string keyPath) = await this.CreateIdentityCertAsync( deviceId, token); EdgeDevice device = await EdgeDevice.GetOrCreateIdentityAsync( deviceId, this.GetNestedEdgeConfig(this.IotHub), this.IotHub, AuthenticationType.SelfSigned, thumbprint, token); Context.Current.DeleteList.TryAdd(device.Id, device); this.runtime = new EdgeRuntime( device.Id, Context.Current.EdgeAgentImage, Context.Current.EdgeHubImage, Context.Current.EdgeProxy, Context.Current.Registries, Context.Current.OptimizeForPerformance, this.IotHub); TestCertificates testCerts; (testCerts, this.ca) = await TestCertificates.GenerateCertsAsync(device.Id, token); await this.ConfigureDaemonAsync( config => { testCerts.AddCertsToConfig(config); config.SetDeviceManualX509( this.IotHub.Hostname, Context.Current.ParentHostname, device.Id, certPath, keyPath); config.Update(); return(Task.FromResult(( "with x509 certificate for device '{Identity}'", new object[] { device.Id }))); }, device, startTime, token); } }, "Completed edge manual provisioning with self-signed certificate"); }
protected virtual async Task SasProvisionEdgeAsync(bool withCerts = false) { using (var cts = new CancellationTokenSource(Context.Current.SetupTimeout)) { CancellationToken token = cts.Token; DateTime startTime = DateTime.Now; this.device = await EdgeDevice.GetOrCreateIdentityAsync( Context.Current.DeviceId.GetOrElse(DeviceId.Current.Generate()), this.GetNestedEdgeConfig(this.IotHub), this.IotHub, AuthenticationType.Sas, null, token); Log.Information($"Device ID {this.device.Id}"); Context.Current.DeleteList.TryAdd(this.device.Id, this.device); this.runtime = new EdgeRuntime( this.device.Id, Context.Current.EdgeAgentImage, Context.Current.EdgeHubImage, Context.Current.EdgeProxy, Context.Current.Registries, Context.Current.OptimizeForPerformance, this.IotHub); // This is a temporary solution see ticket: 9288683 if (!Context.Current.ISA95Tag) { TestCertificates testCerts; (testCerts, this.ca) = await TestCertificates.GenerateCertsAsync(this.device.Id, token); await this.ConfigureDaemonAsync( config => { testCerts.AddCertsToConfig(config); config.SetManualSasProvisioning(Context.Current.ParentHostname.GetOrElse(this.device.HubHostname), this.device.Id, this.device.SharedAccessKey); config.Update(); return(Task.FromResult(( "with connection string for device '{Identity}'", new object[] { this.device.Id }))); }, this.device, startTime, token); } } }
public async Task BeforeAllAsync() { await Profiler.Run( async() => { (string, string, string)rootCa = Context.Current.RootCaKeys.Expect(() => new ArgumentException()); Option <Uri> proxy = Context.Current.Proxy; string deviceId = Context.Current.DeviceId; using (var cts = new CancellationTokenSource(Context.Current.SetupTimeout)) { CancellationToken token = cts.Token; this.iotHub = new IotHub( Context.Current.ConnectionString, Context.Current.EventHubEndpoint, proxy); this.ca = await CertificateAuthority.CreateAsync( deviceId, rootCa, Context.Current.CaCertScriptPath, token); this.daemon = OsPlatform.Current.CreateEdgeDaemon(Context.Current.InstallerPath); await this.daemon.ConfigureAsync( config => { config.SetCertificates(this.ca.Certificates); config.Update(); return(Task.FromResult(("with edge certificates", Array.Empty <object>()))); }, token); var runtime = new EdgeRuntime( deviceId, Context.Current.EdgeAgentImage, Context.Current.EdgeHubImage, proxy, Context.Current.Registries, Context.Current.OptimizeForPerformance, this.iotHub); await runtime.DeployConfigurationAsync(token); } }, "Completed custom certificate setup"); }
protected void BeforeEachModuleTest() { this.iotHub = new IotHub( Context.Current.ConnectionString, Context.Current.EventHubEndpoint, Context.Current.Proxy); this.runtime = new EdgeRuntime( Context.Current.DeviceId, Context.Current.EdgeAgentImage, Context.Current.EdgeHubImage, Context.Current.Proxy, Context.Current.Registries, Context.Current.OptimizeForPerformance, this.iotHub); }
public ManualProvisioningFixture(string deviceIdSuffix) { this.daemon = OsPlatform.Current.CreateEdgeDaemon(Context.Current.InstallerPath); this.iotHub = new IotHub( Context.Current.ConnectionString, Context.Current.EventHubEndpoint, Context.Current.Proxy); this.runtime = new EdgeRuntime( Context.Current.DeviceId + deviceIdSuffix, Context.Current.EdgeAgentImage, Context.Current.EdgeHubImage, Context.Current.Proxy, Context.Current.Registries, Context.Current.OptimizeForPerformance, this.iotHub); }
public virtual async Task SasProvisionEdgeAsync() { using (var cts = new CancellationTokenSource(Context.Current.SetupTimeout)) { CancellationToken token = cts.Token; DateTime startTime = DateTime.Now; EdgeDevice device = await EdgeDevice.GetOrCreateIdentityAsync( DeviceId.Current.Generate(), this.iotHub, AuthenticationType.Sas, null, token); Context.Current.DeleteList.TryAdd(device.Id, device); this.runtime = new EdgeRuntime( device.Id, Context.Current.EdgeAgentImage, Context.Current.EdgeHubImage, Context.Current.Proxy, Context.Current.Registries, Context.Current.OptimizeForPerformance, this.iotHub); await this.ConfigureDaemonAsync( config => { config.SetDeviceConnectionString(device.ConnectionString); config.Update(); return(Task.FromResult(( "with connection string for device '{Identity}'", new object[] { device.Id }))); }, device, startTime, token); } }