Beispiel #1
0
 // TODO: future PR if team says "go", add this as single instance DependencyResolution
 public IoTDeployer(
     IConfig config,
     ICertificateAuthority parentIntermedCertificateAuthority)
 {
     this.config = config ??
                   throw new ArgumentNullException(nameof(config));
     this.parentIntermedCertificateAuthority = parentIntermedCertificateAuthority;
     this.intermedCACertWithKey = this.AcquireCASignedIntermediateCertWithKey();
     this.intermedCACert        = this.intermedCACertWithKey.CloneWithoutKey();
 }
Beispiel #2
0
 // TODO: future PR if team says "go", add this as single instance DependencyResolution
 public IoTHardwareIntegrator(IConfig config,
                              ICertificateAuthority rootCertificateAuthority,
                              IIoTDeployer deployer = null)
 {
     this.config = config ??
                   throw new ArgumentNullException(nameof(config));
     this.rootCertificateAuthority = rootCertificateAuthority;
     this.intermedCACertWithKey    = this.AcquireCASigneIntermediateCertWithKey();
     this.intermedCACert           = this.intermedCACertWithKey.CloneWithoutKey();
     this.Deployer = deployer ?? new IoTDeployer(config, this);
 }
Beispiel #3
0
        private void CollectCerts(ICertificateAuthority ca, X509Certificate2Collection chain)
        {
            chain.Add(ca.personalSignedX509Certificate);

            if (ca.ParentCertificateAuthority == null)
            {
                return;
            }

            this.CollectCerts(ca.ParentCertificateAuthority, chain);
        }
        public void CAIsAbleToAcquireAValidCertAndIsProperlyInitialized()
        {
            // Arrange
            IConfig config = this.config.Object;
            var     provisioningService      = new Mock <IProvisioningService>().Object;
            IRootCertificateAuthority rootCA = new IoTCompany(
                config,
                provisioningService);
            ICertificateAuthority intermedCA = null;

            // Act
            intermedCA = new IoTHardwareIntegrator(config, rootCA);

            // Assert
            Assert.NotNull(intermedCA.personalSignedX509Certificate);
            Assert.NotNull(intermedCA.ParentCertificateAuthority);
            Assert.Equal(rootCA, intermedCA.ParentCertificateAuthority);
            Assert.False(intermedCA.personalSignedX509Certificate.HasPrivateKey);
        }
        public X509CertificatesChainTests(ITestOutputHelper log)
        {
            this.log = log;

            this.config = new Mock <IConfig>();
            this.config.Setup(c => c.IoTCompanyName)
            .Returns("company-x");
            this.config.Setup(c => c.IoTHardwareIntegratorName)
            .Returns("factory-y");
            this.config.Setup(c => c.IoTDeployerName)
            .Returns("technician-z");

            var config = this.config.Object;
            var provisioningService = new Mock <IProvisioningService>().Object;

            //TODO: future PR if team says "go", this needs to be tested with the Dependency Resolution
            this.rootCA      = new IoTCompany(config, provisioningService);
            this.intermed1CA = new IoTHardwareIntegrator(
                config,
                this.rootCA);
            this.intermed2CA = new IoTDeployer(
                config,
                this.intermed1CA);
        }
 /// <summary>
 /// Create the controller.
 /// </summary>
 /// <param name="services"></param>
 public CertificatesController(ICertificateAuthority services)
 {
     _services = services;
 }
Beispiel #7
0
 /// <summary>
 /// Create the controller.
 /// </summary>
 /// <param name="services"></param>
 public DistributionController(ICertificateAuthority services)
 {
     _services = services;
 }