コード例 #1
0
        ////http:*:80:www.abcdefg.com
        ////https:*:443:www.abcdefg.com::CertStoreName\\a03083aabcd6bdfec92214df7e885c9e1e1a864d
        public override void SetBindings(String siteBindings)
        {
            //We need to parse the bindings string
            IISBindingParser.Parse(siteBindings,
                                   delegate(IISBinding iisBinding)
            {
                Binding binding = site.Bindings.FirstOrDefault <Binding>(t => t.BindingInformation.Equals(iisBinding.SMBindString, StringComparison.CurrentCultureIgnoreCase));
                if (binding != null)
                {
                    site.Bindings.Remove(binding);
                }
                binding = site.Bindings.CreateElement("binding");

                binding.Protocol           = iisBinding.Protocol;
                binding.BindingInformation = iisBinding.SMBindString;
                if ((iisBinding.CertificateHash != "") && iisBinding.Protocol.Equals("https", StringComparison.CurrentCultureIgnoreCase))
                {
                    binding.CertificateHash      = SSLCertificates.HexStringToByteArray(iisBinding.CertificateHash);
                    binding.CertificateStoreName = iisBinding.CertificateStore;
                    if (IIS.Version.ProductMajorPart >= 8)
                    {
                        binding.SetAttributeValue("sslFlags", 1);                                        // Enable SNI support
                    }
                }
                site.Bindings.Add(binding);
            });
            CommitServerManagerChanges();
        }
コード例 #2
0
        public override IISBinding FindBinding(IISBinding iisBinding)
        {
            Binding binding = site.Bindings.FirstOrDefault <Binding>(t => t.BindingInformation.Equals(iisBinding.SMBindString, StringComparison.CurrentCultureIgnoreCase));

            if (binding != null)
            {
                IISBinding bnd = new IISBinding()
                {
                    CertificateHash  = (binding.CertificateHash == null) ? "" : SSLCertificates.ByteArrayToHexString(binding.CertificateHash),
                    CertificateStore = binding.CertificateStoreName,
                    Host             = iisBinding.Host,
                    IP       = iisBinding.IP,
                    Protocol = iisBinding.Protocol,
                    Port     = iisBinding.Port
                };
                return(bnd);
            }
            else
            {
                return(null);
            }
        }