我正在测试我创建的WCF Web服务的早期版本.在客户端,当我使用VS来"添加服务引用"时,一切正常.
但是当我尝试使用该服务时,我得到错误,
Run Code Online (Sandbox Code Playgroud)Could not establish trust relationship for the SSL/TLS secure channel with authority **
星号代表服务器的IP地址.
无论如何在服务器上有一个安全证书,但它只是为了测试自己生成的,所以我暂时不担心证书错误.
在客户端,已经为我生成了app.config,
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="BindingName" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="***************"
binding="wsHttpBinding" bindingConfiguration="BindingName"
contract="***************" name="BindingName">
<identity>
<servicePrincipalName value="***************" /> …Run Code Online (Sandbox Code Playgroud) 我如何在 web.config 文件中设置它
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) =>true;
Run Code Online (Sandbox Code Playgroud)