我在.NET Standard 2.0项目中生成了WCF Web服务引用reference.cs
,然后在.NET 4.7.1项目中使用了它,但我得到了"Could not establish secure channel for SSL/TLS with authority"
如果我使用Visual Studio 2015以外的Add Service Reference
生成它,则会得到一个类似的reference.cs类,并且如果将其复制到可以正常工作的.NET standard 2.0项目中,但是会丢失WCF Web服务。有什么办法可以做到这一点?
答案 0 :(得分:1)
确保配置绑定。它们位于.net框架项目的app.config中,但应封装在.NET Standard / .NET Core的BasicHttpBinding
中。
这样,您可以根据需要指定安全设置:
binding.Security.Mode = BasicHttpSecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
从Nuget包System.ServiceModel.Http:
namespace System.ServiceModel
{
public class BasicHttpBinding : HttpBindingBase
{
public BasicHttpBinding();
public BasicHttpBinding(BasicHttpSecurityMode securityMode);
public BasicHttpSecurity Security { get; set; }
public override IChannelFactory<TChannel> BuildChannelFactory<TChannel>(BindingParameterCollection parameters);
public override BindingElementCollection CreateBindingElements();
}
}