Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure HTTPS不适用于Kestrel 3.2.187/ASPNET Core 2.1.5,该版本在具有自定义域的服务结构上运行_Azure_Ssl_Asp.net Core_Azure Service Fabric_Kestrel Http Server - Fatal编程技术网

Azure HTTPS不适用于Kestrel 3.2.187/ASPNET Core 2.1.5,该版本在具有自定义域的服务结构上运行

Azure HTTPS不适用于Kestrel 3.2.187/ASPNET Core 2.1.5,该版本在具有自定义域的服务结构上运行,azure,ssl,asp.net-core,azure-service-fabric,kestrel-http-server,Azure,Ssl,Asp.net Core,Azure Service Fabric,Kestrel Http Server,我们正在远程开发集群上运行一个服务结构应用程序。它由几个有状态和无状态的服务组成,并由运行在Kestrel上的几个前端API提供支持 到目前为止,由于Kestrel未用于生产,因此它被配置为使用自签名证书,该证书也用于反向代理和群集本身,该服务直接在Azure提供的默认域上运行,.cloudapp.Azure.com 我们现在已经到了开发阶段,自签名证书错误变得有问题,第三方回调拒绝连接,因此现在被认为是开始为其使用适当的域和证书的时候了 到目前为止,我已经做了以下工作: 为devcluste

我们正在远程开发集群上运行一个服务结构应用程序。它由几个有状态和无状态的服务组成,并由运行在Kestrel上的几个前端API提供支持

到目前为止,由于Kestrel未用于生产,因此它被配置为使用自签名证书,该证书也用于反向代理和群集本身,该服务直接在Azure提供的默认域上运行,
.cloudapp.Azure.com

我们现在已经到了开发阶段,自签名证书错误变得有问题,第三方回调拒绝连接,因此现在被认为是开始为其使用适当的域和证书的时候了

到目前为止,我已经做了以下工作:

  • devcluster.somexampledomain.com
    ->我们的服务公共IP添加了A记录
  • *.someexampledomain.com
    创建了通配符Azure应用程序证书
  • 已将证书导入Azure密钥库
  • 将证书绑定到群集的Vault机密,将证书拉到
    Cert:/LocalMachine/My/
  • 修改应用程序配置以在初始化Kestrel时使用此证书,并验证在初始化时找到该证书。
    • 已尝试使用和不使用
      UseHsts()
      usehttpseredirection()
    • Kestrel在选项对象上配置了
      Listen(IPAddress.IPv6Any,endpoint.Port,…)
      UseHttps(X509Certificate2)
    • UseUrls(string)
      与默认Url一起使用,默认Url为
      https://+:
      ,但尝试手动添加
      https://*:
      ,甚至实际主机名本身
无论我尝试了什么,都无法建立到服务器的HTTPS连接。尝试其他仍使用旧证书的登台服务器的终结点,它可以正常工作

使用
openssl s_客户端-connect devcluster.someexampledomain.com:-prexit
,我得到:

---
no peer certificate available
---
No client certificate CA names sent
---
ETW上未记录任何错误或异常,一切正常。我怀疑这可能与证书的CN有关,但我已经没有办法尝试找出发生了什么以及如何修复它

我一直在尝试使用Fiddler来研究这个问题,但我并没有从中得到太多的收获,会话只是以
Fiddler.network.https>https握手失败而结束。System.IO.IOException身份验证失败,因为远程方已关闭传输流。


有人知道如何在红隼一侧添加日志吗?我不认为在运行我的集群的Azure虚拟机上安装Fiddler是一个可行的解决方案。

在深入研究Kestrel源代码后,我发现它记录在
“Microsoft AspNetCore Server Kestrel”
“Microsoft Extensions Logging”
下,因此添加了那些我发现发生了什么的转移

连接正在终止,但出现以下异常:

System.ComponentModel.Win32Exception (0x8009030D): The credentials supplied to the package were not recognized
   at System.Net.SSPIWrapper.AcquireCredentialsHandle(SSPIInterface secModule, String package, CredentialUse intent, SCHANNEL_CRED scc)
   at System.Net.Security.SslStreamPal.AcquireCredentialsHandle(CredentialUse credUsage, SCHANNEL_CRED secureCredential)
   at System.Net.Security.SslStreamPal.AcquireCredentialsHandle(X509Certificate certificate, SslProtocols protocols, EncryptionPolicy policy, Boolean isServer)
   at System.Net.Security.SecureChannel.AcquireServerCredentials(Byte[]& thumbPrint, Byte[] clientHello)
   at System.Net.Security.SecureChannel.GenerateToken(Byte[] input, Int32 offset, Int32 count, Byte[]& output)
   at System.Net.Security.SecureChannel.NextMessage(Byte[] incoming, Int32 offset, Int32 count)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
   at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionAdapter.InnerOnConnectionAsync(ConnectionAdapterContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.HttpConnection.ApplyConnectionAdaptersAsync()
这使它成为一种表现

我花了一些时间试图找出解决这个问题的最佳方法,它有一个脚本来修改权限,但听起来不太对劲

事实证明,这可以直接在ApplicationManifest中完成,如下所示:

<Principals>
    <Users>
        <User Name="NETWORK SERVICE" AccountType="NetworkService" />
    </Users>
</Principals>
<Policies>
    <SecurityAccessPolicies>
        <SecurityAccessPolicy ResourceRef="HttpsCert2" PrincipalRef="NETWORK SERVICE" ResourceType="Certificate" />
    </SecurityAccessPolicies>
</Policies>
<Certificates>
    <SecretsCertificate X509FindValue="[HttpsCertThumbprint]" Name="HttpsCert" />
</Certificates>

对于
SecurityAccessPolicy
查找
ResourceRef
SecretsCertificate
,它必须是
SecretsCertificate
,而不是
EndpointCertificate
。由于
EndpointBindingPolicy
需要一个
EndpointCertificate
,我刚刚添加了一个
SecretsCertificate
和一个
EndpointCertificate
,名称不同。他们都引用了同一个证书,所以它起了作用。把它们折叠起来感觉不是特别干净,但这就是我目前的解决方案