如何更改Windows 11上IIS中的SSL配置?
我使用以下代码在IIS中创建了一个网站:
我在服务器证书下导出了IIS证书:
name = "TestSite"
port = 5858
location = location of my install files.
using (ServerManager iisManager = new ServerManager())
{
Site website = iisManager.Sites.Add(name, location, port);
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);
X509Certificate2 certificate = new X509Certificate2(@"c:\certs\testwcf.pfx",
"pwd>");
store.Add(certificate);
var binding = website.Bindings.Add("*:443:", certificate.GetCertHash(), store.Name);
binding.Protocol = "https";
store.Close();
website.Applications[0].ApplicationPoolName = appPoolName;
website.ServerAutoStart = true;
iisManager.CommitChanges();
}
现在发生的是,如果我从Visual Studio运行任何其他开发解决方案 我发现错误:
"An error occurred while using SSL configuration for endpoint 0.0.0.0:87879. The
error status code is contained within the returned data."
开发网站出现后,它将其重定向到Localhost,我似乎无法访问https:// localhost:87879,它使用IIS Express。
我不知道如何 我在哪里可以从哪里看这个想法?
I created a website in IIS using the following code:
I exported a certificate from IIS under Server Certificates to use:
name = "TestSite"
port = 5858
location = location of my install files.
using (ServerManager iisManager = new ServerManager())
{
Site website = iisManager.Sites.Add(name, location, port);
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);
X509Certificate2 certificate = new X509Certificate2(@"c:\certs\testwcf.pfx",
"pwd>");
store.Add(certificate);
var binding = website.Bindings.Add("*:443:", certificate.GetCertHash(), store.Name);
binding.Protocol = "https";
store.Close();
website.Applications[0].ApplicationPoolName = appPoolName;
website.ServerAutoStart = true;
iisManager.CommitChanges();
}
Now whats happening is that if i run any other development solutions from Visual Studio
I get the error:
"An error occurred while using SSL configuration for endpoint 0.0.0.0:87879. The
error status code is contained within the returned data."
When the development site comes up it redirects to localhost and I cant seem to reach https://localhost:87879, which uses IIS Express.
I am not sure how but I think i have broken something in the bindings in IIS which is affecting localhost
Where can i start to look at this any ideas ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设法使它继续前进。
对于任何有此问题的人,请尝试以下内容:
从高架命令提示下运行:
用您的URL代替urltoyoursite。
例如
CD C:\ Program Files(x86)\ iis Express
iisexpressadmincmd.exe setupsslurl -url:https:// localhost:44387/-isselfSigned
Managed to get it going.
For any one having this issue try the following:
From an elevated command prompt run:
Replacing urlToYourSite with your url.
e.g.
cd C:\Program Files (x86)\IIS Express
IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:44387/ -UseSelfSigned