当 运行 提琴手时得到 "Could not establish trust relationship for the SSL/TLS secure channel with authority"

getting "Could not establish trust relationship for the SSL/TLS secure channel with authority" when running fiddler

我有一个向第三方网络服务发送 https 请求的 WCF 客户端应用程序。一切正常。我收到了正确答案。

我已经安装了 fiddler 并信任它的根证书来捕获和编码 https 流量。但是现在我的请求收到错误 "Could not establish trust relationship for the SSL/TLS secure..."

我在网上搜索了很多关于这个错误的信息。但每次解决方案都是我需要信任提琴手根证书。由于我是从一开始就这样做的,所以看起来这不是解决我问题的方法。

这是我发送请求的代码片段:

AsymmetricSecurityBindingElement securityBindingElement = new AsymmetricSecurityBindingElement();
securityBindingElement.InitiatorTokenParameters = new X509SecurityTokenParameters { InclusionMode = SecurityTokenInclusionMode.Never };
securityBindingElement.RecipientTokenParameters = new X509securityTokenParameters();
securityBindingElement.EnableUnsecuredResponse = true;
securityBindingElement.EndpointSupportingTokenParameters.Signed.Add(new X509SecurityTokenParameters());

CustomBinding binding = new CustomBinding(securityBindingElement, new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8), new HttpsTransportBindingElement());

EndpointAddress endpoint = new EndpointAddress(new Uri(URL), new X509CertificateEndpointIdentity(serverCertificate));

ChannelFactory<type> channelFactory = new ChannelFactory<type>(binding, endpoint);
channelFactory.Credentials.ClientCertificate.Certificate = clientX509Certificaat;
channelFactory.Credentials.ServiceCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck;
channelFactory.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign;

type client = channelFactory.CreateChannel();
client.request();

有人知道这里出了什么问题吗?

我将代码更改为:

AsymmetricSecurityBindingElement securityBindingElement = new AsymmetricSecurityBindingElement();
securityBindingElement.InitiatorTokenParameters = new X509SecurityTokenParameters { InclusionMode = SecurityTokenInclusionMode.Never };
securityBindingElement.RecipientTokenParameters = new X509securityTokenParameters();
securityBindingElement.EnableUnsecuredResponse = true;
securityBindingElement.EndpointSupportingTokenParameters.Signed.Add(new X509SecurityTokenParameters());

CustomBinding binding = new CustomBinding(securityBindingElement, new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8), new HttpsTransportBindingElement());

EndpointAddress endpoint = new EndpointAddress(new Uri(URL));

ChannelFactory<type> channelFactory = new ChannelFactory<type>(binding, endpoint);
channelFactory.Credentials.ClientCertificate.Certificate = clientX509Certificaat;
channelFactory.Credentials.ServiceCertificate.DefaultCertificate = serverX509Certificaat;
channelFactory.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign;

type client = channelFactory.CreateChannel();
client.request();

我不清楚为什么我不再有问题了。有人吗?