【问题标题】:Azure App Service "The Client Certificate Credentials Were Not Recognized"Azure 应用服务“无法识别客户端证书凭据”
【发布时间】:2019-08-25 09:08:54
【问题描述】:

当我在本地(以发布模式)运行我的 ASP dotnet 核心 API 时,它使用 WCF 和客户端证书 (X509Certificate2) 进行外部调用,正确返回数据。但是,当此 API 部署为 Azure 应用服务时,它会显示“无法识别客户端证书凭据”。 X509Certificate2 已从文件系统正确加载(从远程调试可见)。

我尝试使用普通的 HttpClient 进行调用并添加证书,但这给了我相同的结果。 我们还尝试使用 CertificateStore,结果相同。

private async Task ProcessRequestAsync(string endpoint, X509Certificate2 certificate, Func<SsoSoapType, Task> action)
        {
            BasicHttpsBinding binding = new BasicHttpsBinding();
            EndpointAddress endpointAddress = new EndpointAddress(new Uri(endpoint));
            ChannelFactory<SsoSoapType> factory = new ChannelFactory<SsoSoapType>(binding, endpointAddress);
            factory.Credentials.ClientCertificate.Certificate = certificate;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

            await action(factory.CreateChannel());

            if (factory != null)
            {
                if (factory.State == CommunicationState.Faulted)
                    factory.Abort();
                else
                    factory.Close();
            }
        }

我希望部署的版本与我的本地版本一样。但显然情况并非如此。

有人可以解释这是哪里出错了吗? 还是 Azure 门户中的某些设置需要相应设置造成的?

亲切的问候, 雅克

【问题讨论】:

    标签: azure wcf soap certificate channelfactory


    【解决方案1】:

    好的,经过深入研究后,我发现我的 Azure App Service 已设置为托管计划“D1”。这意味着机器在不同的应用程序服务之间共享,因此无法使用证书存储(因为您将能够看到其他人的证书)。升级到托管计划“B1”后,问题得到解决。

    【讨论】:

      猜你喜欢
      • 2018-07-11
      • 1970-01-01
      • 2011-08-19
      • 2018-04-14
      • 2015-04-18
      • 1970-01-01
      • 2013-03-01
      • 2016-01-27
      • 2014-08-17
      相关资源
      最近更新 更多