简体   繁体   English

启动 Kestrel 服务器时未使用 ApplicationManifest 中的 EndpointCertificate

[英]EndpointCertificate in ApplicationManifest not being used when starting Kestrel server

I was following this article to try and get an https endpoint running with the certificate specified in the manifest.我正在关注本文以尝试使用清单中指定的证书运行 https 端点。

So far I have only tried this on my local dev cluster through VS so I don't know if that is the problem, it is possibly also important to note that the target cluster for this is a standalone cluster.到目前为止,我只通过 VS 在我的本地开发集群上尝试过这个,所以我不知道这是否是问题,注意这个目标集群是一个独立集群可能也很重要。

Anyway, when the service tries to start up, it comes up with an error:无论如何,当服务尝试启动时,会出现错误:

Unable to configure HTTPS endpoint.无法配置 HTTPS 端点。 No server certificate was specified, and the default developer certificate could not be found.未指定服务器证书,并且找不到默认的开发者证书。

The relevant sections of my manifests look as described in the link:我的清单的相关部分看起来如链接中所述:

Service Manifest服务清单

  <Resources>
    <Endpoints>
      <Endpoint Name="EndpointName" Protocol="https"/>
    </Endpoints>
  </Resources>

Application manifest:申请清单:

  <Policies>
    <EndpointBindingPolicy EndpointRef="EndpointName" CertificateRef="TestCert1" />
  </Policies>
  ...
  <Certificates>
    <EndpointCertificate X509FindValue="ad a5 9c 03 44 5a 40 1a 5e 2d f2 72 24 93 30 e8 b0 85 b0 bb" Name="TestCert1" />
  </Certificates>

The code that runs on the kestrel startup looks like this:在 kestrel 启动时运行的代码如下所示:

protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
  => new[]
  {
     new ServiceReplicaListener(
        serviceContext => new KestrelCommunicationListener(
            serviceContext,
            "EndpointName",
            (url, listener) =>
            {
              ServiceEventSource.Current.ServiceMessage(serviceContext, $"Opening on {url}");

              return new WebHostBuilder()
                  .UseKestrel()
                  .ConfigureServices(
                     services => services
                        .AddSingleton(serviceContext)
                        .AddSingleton(StateManager)
                  .UseContentRoot(Directory.GetCurrentDirectory())
                  .UseStartup<Startup>()
                  .UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.UseUniqueServiceUrl)
                  .UseUrls(url)
                  .Build();
            })),
  };

Everything was working fine when I was just using HTTP.当我只使用 HTTP 时,一切正常。 Any ideas on what I am doing wrong?关于我做错了什么的任何想法?

Also, is this mechanism supported?另外,是否支持这种机制? The reason I ask is because I also found the type definition for the endpoint that says not to use the "Certificate" property as it is not supported我问的原因是因为我还发现端点的类型定义说不使用“证书”属性,因为它不受支持

Your Application Manifest looks fine, that's how I would configure an HTTPS endpoint for a WebAPI in Service fabric.您的应用程序清单看起来不错,这就是我在 Service Fabric 中为 WebAPI 配置 HTTPS 端点的方式。 I haven't configured with Kestrel, but the error you got looks like a wrong config issue.我还没有配置 Kestrel,但你得到的错误看起来像是一个错误的配置问题。

I hope this helps.我希望这有帮助。 Here's a tutorial from Microsoft with a different approach.这是来自 Microsoft 的使用不同方法的教程。 Add an HTTPS endpoint to an ASP.NET Core Web API front-end service using Kestrel 使用 Kestrel 将 HTTPS 端点添加到 ASP.NET Core Web API 前端服务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法找到Kestrel使用的自签名可信证书 - Cant find self signed trusted certificate used by Kestrel 为什么Microsoft.AspNet.Server.Kestrel.Https .NET 4.5.1是不可知的? - Why is Microsoft.AspNet.Server.Kestrel.Https .NET 4.5.1 agnostic? 将代理服务器用于 LAN 时的 PowerShell 远程处理 - PowerShell Remoting when proxy server is used for LAN 是否可以为 Kestrel 服务器的单个实例指定 2 个不同的 SSL 证书? - Is it possible to specify 2 different SSL certificates for a single instance of Kestrel server? 向 HTTPS 端点发出请求时,Kestrel 是否需要 UseHttps? - Does Kestrel need UseHttps when making a request to an HTTPS endpoit? 启动SQL服务器 - Starting a SQL server HTTPS服务器永远启动 - Https server starting forever 从服务器重定向时,页面从HTTPS重定向到HTTP - When redirecting from server, the page being redirected from HTTPS to HTTP 如何为部署在生产服务器上的自包含 Kestrel/Blazor 应用程序指定服务器证书? - How to specify server certificate for a self-contained Kestrel/Blazor application deployed on a production server? 使用https时,Web服务器是否使用SSL请求资源? - When https is used, does the web server request resources using SSL?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM