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

问题描述 投票:0回答:1

我正在关注this article,试图使https端点运行清单中指定的证书。

到目前为止,我仅通过VS在我的本地开发集群上进行了尝试,所以我不知道这是否是问题,注意这一点的目标集群是独立集群也是很重要的。

无论如何,当服务尝试启动时,它会出现错误:

无法配置HTTPS端点。未指定服务器证书,并且找不到默认的开发人员证书。

清单的相关部分的外观如链接中所述:

服务清单

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

应用清单:

  <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>

在红est启动时运行的代码如下:

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();
            })),
  };

当我刚使用HTTP时,一切工作正常。关于我在做什么错的任何想法吗?

此外,是否支持此机制?我问的原因是因为我还发现the type definition for the endpoint表示不使用“证书”属性,因为它不受支持]

https azure-service-fabric kestrel service-fabric-on-premises
1个回答
0
投票

您的应用程序清单看起来不错,这就是我为Service架构中的WebAPI配置HTTPS端点的方式。我尚未使用Kestrel进行配置,但是出现的错误似乎是错误的配置问题。

我希望这会有所帮助。这是来自Microsoft的另一种方法的教程。Add an HTTPS endpoint to an ASP.NET Core Web API front-end service using Kestrel

© www.soinside.com 2019 - 2024. All rights reserved.