2016-07-16 31 views
5

我使用https://github.com/ebekker/ACMESharp我的SSL在我的@Home Web服务器(这是免费的!O)。这是相当手动的,但在维基上注意到它提到了另一个项目https://github.com/Lone-Coder/letsencrypt-win-simple,这是一个用于自动申请,下载和安装SSL证书到您的Web服务器的GUI。静态文件.netcore应用

GUI用于验证域的方法是您自己的,是通过在[webroot]/.well-known/[randomFile](不带扩展名)内创建一个随机命名的文件,并带有随机字符串文本。在[webroot]上运行.dotnetcore应用程序时,即使按照IIS中更改“处理程序映射”的说明进行操作,我也无法提供该文件。

似乎我可以通过直接导航到他们的文件[webRoot]/wwwroot/[whatever] - 为什么我不能在[webroot]/.well-known/[randomFile]

任何人都知道解决的办法?我可以删除.netcore应用程序,然后运行SSL证书安装,但是这种安装需要每2-3个月进行一次,而且由于它是手动的,所以我更愿意弄清楚如何以正确的方式进行安装。

回答

3

我发现我需要这里的信息:我需要改变这个https://docs.asp.net/en/latest/fundamentals/static-files.html

基本上在我的Statup.cs:

 // allows for the direct browsing of files within the wwwroot folder 
     app.UseStaticFiles(); 

     // MVC routes 
     app.UseMvc(routes => 
     { 
      routes.MapRoute(
       name: "default", 
       template: "{controller=Home}/{action=Index}/{id?}"); 
     }); 

这样:

 // allows for the direct browsing of files within the wwwroot folder 
     app.UseStaticFiles(); 

     // Allow static files within the .well-known directory to allow for automatic SSL renewal 
     app.UseStaticFiles(new StaticFileOptions() 
     { 
      ServeUnknownFileTypes = true, // this was needed as IIS would not serve extensionless URLs from the directory without it 
      FileProvider = new PhysicalFileProvider(
        Path.Combine(Directory.GetCurrentDirectory(), @".well-known")), 
      RequestPath = new PathString("/.well-known") 
     }); 

     // MVC routes 
     app.UseMvc(routes => 
     { 
      routes.MapRoute(
       name: "default", 
       template: "{controller=Home}/{action=Index}/{id?}"); 
     }); 

编辑 - 注该目录“.well-known”仅在Web服务器上创建,当我开始在本地重新开发时,由于“.well-known”目录不存在。所以现在我只在我的项目中有一个空目录,但至少我的SSL更新是自动的! :D