Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 27852

Bind SSL to a site

$
0
0

Hello

I'm trying to add a SSL certificate to a site from c#, but I can't get it to work. It keep throw "Value does not fall within the expected range."

The certificate is a self-signed.

My code:

using (ServerManager manager = new ServerManager())
            {
                Site site = manager.Sites["mysite"];

                if (site != null)
                {
                    byte[] certificateHash = Encoding.ASCII.GetBytes("672edf12189159aa486805ef0e42ce21");

                    Binding binding = site.Bindings.CreateElement();
                    binding.Protocol = "https";
                    binding.CertificateHash = certificateHash;
                    binding.CertificateStoreName = "*.myssl";
                    binding.BindingInformation = "*:443:mysite";

                    site.Bindings.Add(binding);

                    manager.CommitChanges();
                }
            }

Any idea what I doing wrong?

Thanks,

Michael Petersen


Viewing all articles
Browse latest Browse all 27852

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>