2016-07-16 57 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