Let's Encrypt confirmation on IIS not working

Viewed 5067

I'm trying to use the Certify SSL Manager to configure SSL certificates from Let's Encrypt on my IIS server, but it fails during the check.

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

This works:
https://dev.mywebsite.com/well-known/acme-challenge/configcheck https://dev.mywebsite.com/.well-known/acme-challenge/test.txt

So I assumed it's the . before well-known. But the fact that test.txt works confuses me.

I've already configured the directory according to this discussion: https://github.com/ebekker/ACMESharp/issues/15

I have a bunch of rewrite stuff in my web.config, but even if I remove that section completely, it still fails.

3 Answers

The configcheck url is a file, not a directory. Make sure that file exists on disk (i.e. C:\inetpub\wwwroot\.well-known\acme-challenge\configcheck) in your webroot. Then try to load your links with this barebones web.config in your website root directory (if using ASP.NET):

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

If that works, try slowly adding back in your web.config sections including routes/rewrite until you figure out what's causing the problem.

If using ASP.NET Core with a wwwroot folder hosting your static files, you'll have to modify your config in Startup.cs instead:

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
}

I had to modify the web.config as follow to fix the error:

<?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>
Related