2017-04-14 41 views
4

我试图安装letsencrypt证书,但是出现错误,我认为这与Certify没有任何关系。问题是我的web.config配置如何处理我的Asp.Net Core - Angular2应用程序。为letsencrypt设置web.config - 使用Asp.NET Core和Angular 2(Javascript服务)进行认证

我没有配置的web.config,Javascript services做到了。在的Certify网页写在页面的关于我的问题的底部:

我得到的错误“为扩展名的内容自动检查失败。” 这意味着你的Web服务器配置为不允许没有 扩展文件送达现场访客。不幸的是,这是一个 要求的顺序让加密服务为它的时候你 申请一个证书(详细信息)获取该站点内自动创建的 验证文件。

为了帮助这一要求,我们会尝试自动配置此 你。如果您查看{your site} .well-known \ acme-challenge,您将看到我们已经创建了一个web.config和一个名为configcheck的文件。 如果您无法浏览本ConfigCheck的文件在网络浏览器 (HTTP:// {网站} /众所周知/ ACME挑战/ ConfigCheck的那么 让加密服务无法访问它需要的文件或者,你可以 编辑该文件夹中的web.config文件以获得名的文件 的工作,那么你可以重新申请证书。对于 是A mimeMap条目“”或“*”通常工作取决于你的工作系统 版本。

可一些专家的请帮我纠正,将支持任何letsencrypt需要我的web.config文件。目前任何通过WebBrowser无法访问.well-known/acme-challenge中的内容。

我的web.config:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.webServer> 
    <handlers> 
     <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/> 
    </handlers> 
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/> 
    <rewrite> 
     <rules> 
     <rule name="redirect" stopProcessing="true"> 
      <match url="^$" /> 
      <action type="Rewrite" url="/index.html" /> 
     </rule> 
     <rule name="Angular 2 pushState routing" stopProcessing="true"> 
      <match url=".*" /> 
      <conditions logicalGrouping="MatchAll"> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
      <add input="{REQUEST_FILENAME}" pattern=".*\.[\d\w]+$" negate="true" /> 
      <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" /> 
      <add input="{REQUEST_URI}" pattern="^/(.well-known)" negate="true"/> 
      <add input="{REQUEST_URI}" pattern="^/(signin)" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="/index.html" /> 
     </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 

谢谢。
Screenshot of error

+0

'不能通过WebBrowser访问是否就像403?或404? –

回答

1

将此放在.\.well-known\acme-challenge\Web.Config文件中,紧挨着Lets Encrypt DNS验证文件。无需更改已有的Web.Config。所有这一切都告诉IIS在没有扩展名的情况下在这个Web.Config所在的目录中使用MIME类型text/plain咳嗽文件,因为Lets Encrypt期望这样做。

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <staticContent> 
      <mimeMap fileExtension="." mimeType="text/plain" /> 
     </staticContent> 
     <handlers> 
      <clear /> 
      <add name="StaticFile" path="*" verb="GET" modules="StaticFileModule" resourceType="Either" /> 
     </handlers> 
    </system.webServer> 
</configuration> 
0

我有同样的问题。就我而言,我还必须将此代码添加到我的Startup.cs中。

此外,一定要加的。好了已知目录。这是一个隐藏的文件夹 - 所以请使用名称“.well-known”。 (尾点将消失)。 Windows不会允许没有开始点和结束点的新隐藏文件夹。

using Microsoft.Extensions.FileProviders; 
using System.IO; 
using Microsoft.AspNetCore.Http; 
public class Startup 
{ 
    public void Configure(IApplicationBuilder app, IHostingEnvironment env) 
    { 
     app.UseStaticFiles(); 
     app.UseStaticFiles(new StaticFileOptions 
     { 
      FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @".well-known")), 
      RequestPath = new PathString("/.well-known"), 
      ServeUnknownFileTypes = true // serve extensionless files 
     }); 
    } 
} 
0

我遇到的问题与acme-challenge文件夹中的默认web.config是应用程序主机。配置包含:

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

的极致挑战的web.config的处理程序部分,因此没有与结果允许的挑战失败了。在这种情况下,解决方案是: 变化对ApplicationHost.config行:

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

或... 删除处理程序从ACME挑战文件夹中的web.config的设置。

相关问题