Example #1
0
        private void AddToIIS(CertificateInfo certificate)
        {
            var  host = certificate.HostNames.First();
            Site site;

            if (_tempSiteId == null)
            {
                site             = _iisClient.ServerManager.Sites.Add(host, "http", string.Format("*:80:{0}", host), "X:\\");
                _tempSiteId      = site.Id;
                _tempSiteCreated = true;
            }
            else
            {
                site = _iisClient.ServerManager.Sites.Where(x => x.Id == _tempSiteId).FirstOrDefault();
            }

            SSLFlags flags = SSLFlags.SNI;

            if (certificate.Store == null)
            {
                flags |= SSLFlags.CentralSSL;
            }
            _iisClient.AddOrUpdateBindings(site, host, flags, certificate.Certificate.GetCertHash(), certificate.Store?.Name, 443);
            _iisClient.Commit();
        }
Example #2
0
        private void AddToIIS(CertificateInfo certificate)
        {
            var  host = certificate.HostNames.First();
            Site site;

            if (_tempSiteId == null || _tempSiteId == 0)
            {
                site             = _iisClient.ServerManager.Sites.Add(host, "http", $"*:80:{host}", "X:\\");
                _tempSiteId      = site.Id;
                _tempSiteCreated = true;
            }
            else
            {
                site = _iisClient.WebSites.Where(x => x.Id == _tempSiteId).FirstOrDefault();
                if (site == null)
                {
                    _log.Error("Unable to find IIS SiteId {Id} which is required for validation", _tempSiteId);
                    return;
                }
            }

            var flags = SSLFlags.SNI;

            if (certificate.Store == null)
            {
                flags |= SSLFlags.CentralSSL;
            }
            _iisClient.AddOrUpdateBindings(new Binding[] { }, site, host, flags, certificate.Certificate.GetCertHash(), certificate.Store?.Name, 443, "*", false);
            _iisClient.Commit();
        }
Example #3
0
        void IInstallationPlugin.Install(CertificateInfo newCertificate, CertificateInfo oldCertificate)
        {
            SSLFlags flags = 0;

            if (newCertificate.Store == null)
            {
                if (_iisClient.Version.Major < 8)
                {
                    var errorMessage = "Centralized SSL is only supported on IIS8+";
                    _log.Error(errorMessage);
                    throw new InvalidOperationException(errorMessage);
                }
                else
                {
                    flags |= SSLFlags.CentralSSL;
                }
            }
            foreach (var split in _targetPlugin.Split(_renewal.Binding))
            {
                _iisClient.AddOrUpdateBindings(split, flags, newCertificate, oldCertificate);
            }
        }
        private void AddToIIS(string host, byte[] certificateHash, X509Store store)
        {
            Site site;

            if (_tempSiteId == null)
            {
                site        = _iisClient.ServerManager.Sites.Add(host, "http", string.Format("*:80:{0}", host), "X:\\");
                _tempSiteId = site.Id;
            }
            else
            {
                site = _iisClient.ServerManager.Sites.Where(x => x.Id == _tempSiteId).FirstOrDefault();
            }

            SSLFlags flags = SSLFlags.SNI;

            if (Program.OptionsService.Options.CentralSsl)
            {
                flags |= SSLFlags.CentralSSL;
            }
            _iisClient.AddOrUpdateBindings(site, host, flags, certificateHash, store?.Name);
            _iisClient.Commit();
        }