【问题标题】:EndpointCertificate in ApplicationManifest not being used when starting Kestrel server启动 Kestrel 服务器时未使用 ApplicationManifest 中的 EndpointCertificate
【发布时间】:2020-04-02 08:31:45
【问题描述】:

我正在关注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>

在红隼启动时运行的代码如下所示:

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

    您的应用程序清单看起来不错,这就是我为 Service Fabric 中的 WebAPI 配置 HTTPS 端点的方式。我还没有配置 Kestrel,但是你得到的错误看起来像是一个错误的配置问题。

    我希望这会有所帮助。这是 Microsoft 提供的采用不同方法的教程。 Add an HTTPS endpoint to an ASP.NET Core Web API front-end service using Kestrel

    【讨论】:

    • 是的,我已经看到了那个链接,并且最初是这样工作的。浏览清单看起来是一种更简洁的方式,所以我想我应该试一试......
    • 您通常使用什么而不是 Kestrel?
    • 只是一个自托管的 WebAPI
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多