我在用着https://github.com/ebekker/ACMESharp https://github.com/ebekker/ACMESharp在我的 @home 网络服务器上使用 SSL(它是免费的!:O)。这是相当手动的,但注意到在维基上它提到了另一个项目https://github.com/Lone-Coder/letsencrypt-win-simple https://github.com/Lone-Coder/letsencrypt-win-simple这是一个 GUI,用于自动申请、下载 SSL 证书并将其安装到您的 Web 服务器。
GUI 用于验证域是否属于您的方法是创建一个随机命名的文件,其中包含随机文本字符串[webroot]/.well-known/[randomFile]
不带扩展名。当 .dotnetcore 应用程序在此 [webroot] 上运行时,即使按照在 IIS 下更改“处理程序映射”的说明进行操作,我也无法提供该文件。
看来我可以通过直接导航到文件来提供文件[webRoot]/wwwroot/[whatever]
-那我为什么不能进去[webroot]/.well-known/[randomFile]
?
有人知道解决这个问题的方法吗?我可以删除 .netcore 应用程序,然后运行 SSL 证书安装,但此安装需要每 2-3 个月进行一次,而且由于它是手动的,我更愿意弄清楚如何以正确的方式进行安装。
我在这里找到了我需要的信息:https://docs.asp.net/en/latest/fundamentals/static-files.html https://docs.asp.net/en/latest/fundamentals/static-files.html
基本上在我的 Startup.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?}");
});
to this:
// 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)