让我们在 IIS 上加密确认不起作用

Let's Encrypt confirmation on IIS not working

我正在尝试使用 Certify SSL Manager 在我的 IIS 服务器上配置来自 Let's Encrypt 的 SSL 证书,但在检查过程中失败。

https://dev.mywebsite.com/.well-known/acme-challenge/configcheck/

这个有效:
https://dev.mywebsite.com/well-known/acme-challenge/configcheck https://dev.mywebsite.com/.well-known/acme-challenge/test.txt

所以我认为是 .在众所周知之前。但是 test.txt 起作用的事实让我很困惑。

我已经根据这个讨论配置了目录: https://github.com/ebekker/ACMESharp/issues/15

我的 web.config 中有一堆重写的东西,但即使我完全删除该部分,它仍然失败。

configcheck url 是文件,不是目录。确保该文件存在于您的 webroot 的磁盘上(即 C:\inetpub\wwwroot\.well-known\acme-challenge\configcheck)。然后尝试在您的网站根目录中加载带有此准系统 web.config 的链接(如果使用 ASP.NET):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension="." mimeType="application/unknown" />
        </staticContent>
    </system.webServer>
</configuration>

如果可行,请尝试慢慢添加回 web.config 部分,包括 routes/rewrite,直到找出导致问题的原因。

如果使用 ASP.NET Core 和 wwwroot 文件夹托管您的静态文件,您必须在 Startup.cs 中修改您的配置:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    string filepath = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot/.well-known");
    app.UseStaticFiles(new StaticFileOptions()
    {
        FileProvider = new PhysicalFileProvider(filepath),
        RequestPath = new PathString("/.well-known"),
        ServeUnknownFileTypes = true
    });
    // ... your other startup code here
}

也许检查 acme-challenge web.config 是否在处理程序部分中包含冲突。为此,请打开 IIS 管理器,找到 acme-challenge 文件夹,然后双击处理程序映射图标。就我而言,这导致了错误。

我 运行 在 acme-challenge 文件夹中使用默认 web.config 的问题是 applicationhost.config 包含:

<section name="handlers" overrideModeDefault="Deny" />

acme-challenge web.config 中的 handlers 部分因此不被允许,结果挑战失败。在这种情况下,解决方案是: 将 applicationhost.config 行更改为:

<section name="handlers" overrideModeDefault="Allow" />

或者... 从 acme-challenge 文件夹中的 web.config 中删除处理程序设置。

applicationhost.config 可以在这里找到:c:\windows\system32\inetsrv\config

我必须按如下方式修改 web.config 以修复错误:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
      <staticContent>
         <mimeMap fileExtension="*" mimeType="text/plain" />
      </staticContent>
      <handlers>
         <clear />
         <add name="StaticFile" path="*" verb="*" type=""
            modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
            scriptProcessor="" resourceType="Either" requireAccess="Read"
            allowPathInfo="true" preCondition="" responseBufferLimit="4194304" />
      </handlers>
   </system.webServer>
</configuration>