Could not establish secure channel for SSL/TLS with authority '*'

前端 未结 9 1664
感情败类
感情败类 2020-12-14 17:59

I must consume a PHP webservice which has a SSL certificate. My .net 3.5 Class library references the webservice with \'Add Service references\' in Visualstudio 2010 (WCF ri

9条回答
  •  无人及你
    2020-12-14 18:40

    In case it helps anyone else, using the new Microsoft Web Service Reference Provider tool, which is for .NET Standard and .NET Core, I had to add the following lines to the binding definition as below:

    binding.Security.Mode = BasicHttpSecurityMode.Transport;
    binding.Security.Transport = new HttpTransportSecurity{ClientCredentialType = HttpClientCredentialType.Certificate};
    

    This is effectively the same as Micha's answer but in code as there is no config file.

    So to incorporate the binding with the instantiation of the web service I did this:

     System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
     binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
     binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Certificate;
     var client = new WebServiceClient(binding, GetWebServiceEndpointAddress());
    

    Where WebServiceClient is the proper name of your web service as you defined it.

提交回复
热议问题