在IIS上发布时出现System.ServiceModel.Security.SecurityNegotiationException,在IIS Express中可以正常工作

时间:2019-01-18 07:39:03

标签: c# asp.net .net wcf ssl

我有一个在IIS Express上运行良好的SOAP客户端,但是在IIS上发布时会引发以下异常:

  

System.ServiceModel.Security.SecurityNegotiationException:无法   建立具有权限的SSL / TLS安全通道....

这是使用其安全性选项创建客户端的功能:

internal static MixedBulkServices.MixedBulkServicesClient GetMixedBulkService(string endPoint)
{
    //Defines a secure binding with certificate authentication
    WSHttpBinding binding = new WSHttpBinding();
    binding.Security.Mode = SecurityMode.Transport;
    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

    //Creates ServiceClient, attach transport-binding, Endpoint and the loaded certificate
    MixedBulkServices.MixedBulkServicesClient service = new MixedBulkServices.MixedBulkServicesClient(binding, new EndpointAddress(endPoint));

    X509Certificate2 cert = new X509Certificate2(GetCertificatePath(), Properties.Settings.Default.PrivateKeyPassword, X509KeyStorageFlags.PersistKeySet);

    service.ClientCredentials.ClientCertificate.Certificate = cert;

    return service;
}

我已经在服务器中安装了所有.NET 4.6选项和WCF服务。 任何建议将不胜感激

0 个答案:

没有答案