Hi guys,
I am attempting to code to add bindings to my site. I am able to do so for both http and https protocols with the following code :-
string[] ports = { "80", "443" };
string[] protocols = { "http", "https" };
while (i < 2) {
using (ServerManager serverManager = new ServerManager()) {
var smSite = serverManager.Sites.FirstOrDefault(s => s.Name.Contains("MySite"));
if (smSite != null) {
BindingCollection bindingCollection = smSite.Bindings;
Binding binding = smSite.Bindings.CreateElement("binding");
binding["protocol"] = protocols[i];
binding["bindingInformation"] = string.Format("{0}:{1}:{2}", ip, ports[i], hostName);
bindingCollection.Add(binding);
serverManager.CommitChanges();
}
i++;
}
}
However, for https, I need to set the SSL certificate as well. With my code, I am able to create the bindings for https but without any certificate set. How do I create(add) the https bindings with certificate definition? Any sample code is highly appreciated.