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

error in adding certification to web site using c#

$
0
0

Hello,

I run the attached code and get this error message:

{"Value does not fall within the expected range."}

I know that the certificationHash is the problem but i'm using a valid one (I know it because from the iismanager i can set this certification).

What i'm doing worng ?

Thanks,

Hai

the stack trace:

   at Microsoft.Web.Administration.Interop.IAppHostMethodInstance.Execute()    at Microsoft.Web.Administration.ConfigurationMethodInstance.Execute()    at Microsoft.Web.Administration.Binding.AddSslCertificate(Byte[] certificateHash, String certificateStoreName)   at Microsoft.Web.Administration.BindingManager.BindingTransaction.Commit()    at Microsoft.Web.Administration.BindingManager.Save()    at Microsoft.Web.Administration.ServerManager.CommitChanges()    at PmIISAgent.PmIIS.AddWithCertificate(String name, String bindingInformation, String physicalPath, String certificateHash, String bindingProtocol, Boolean ServerAutoStart, String appPoolName) in D:\ProductionMap\PMAgent\DedicatedAgents\trunk\haiAgents\pmIISAgent\pmIISAgent\pmIISAgent\pmIISAgent.cs:line 102

my code:

 

site = serverManager.Sites[name];

BindingCollection bindingCollection = site.Bindings;

Binding binding = site.Bindings.CreateElement("binding"); binding["protocol"] = bindingProtocol; binding["bindingInformation"] = bindingInformation;

binding.CertificateHash = lcertificateHash.ToArray<byte>();

// valid certification ="‎e19f241143b94c92eb85d3f4e72aba3b6d60603b";//certificateHash;

binding["certificateStoreName"] = "MY";

bindingCollection.Add(binding);

serverManager.CommitChanges();


Viewing all articles
Browse latest Browse all 28504

Latest Images

Trending Articles



Latest Images

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