WCF 调用另一个 WCF:无法建立 SSL/TLS 的信任关系
我有两个 WCF 托管在两个不同的 HTTPS 网站上,并且具有不同的证书。 WCF(a) 使用 if 子句调用 WCF(b),反之亦然,以取消可能的无限循环。
每次调用两个 WCF 的方法时,都会返回错误:
Could not establish trust relationship for the SSL/TLS
我尝试在受信任的根证书中安装证书,但错误仍然出现。不幸的是,避免 WCF 调用另一个 WCF 并不是一种选择。
有什么解决办法吗?
更新:
我尝试在同一个网站上托管这两个网站并且它有效,所以我认为这是特定于所使用的证书的?那么是否必须使用同一个证书呢?或者是否有可能使用具有不同证书的不同网站?
I have two WCF hosted on two different HTTPS websites with different certificates. WCF(a) calls WCF(b) and vice-versa with an if clause to cancel the possible infinite loop.
Every time the method of both WCF is called, it returns the error:
Could not establish trust relationship for the SSL/TLS
I tried installing the certificates in the Trusted Root Certificates but the error still appears. Avoiding the WCF-calling-another-WCF is not an option, unfortunately.
Any fix for this?
UPDATE:
I've tried hosting both in the same website and it worked so I'm thinking this is specific to the certificate being used? So should the same certificate must be used? or is there a possible way to use different websites with different certificates?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您使用自签名证书时,您需要让访问 WCF 服务的客户端中的证书验证返回 true。
代码如下所示:
只需在调用服务方法之前放置此代码即可。
另外,由于您有 2 个服务 A 和 B 相互调用,因此当您拨打电话时,上述代码应该位于两个地方。以上是信任证书,因为它不是来自受信任的证书提供商。
When you use self signed certificates you need to have the certificate validation return true in your client that access the WCF service.
The code is as shown below:
Just place this code before you invoke your service method.
Also Since you have 2 services A and B calling each other the above code should be in both places when you make a call. The above is to trust the certificate as its not from a trusted certificate provider.
使用 SSL 自签名证书时,您需要注意以下事项:
可以通过将服务托管在 IIS 下并使用 IIS 生成服务器证书来满足这些步骤。
另请注意,wcf 通常要求将 CRL 附加到证书。但这也可以使用 certmgr.exe 生成。
Using self signed certificates for SSL you need to be aware of the following:
These steps can be satisfied by hosting the services under IIS, and use IIS to generate the server certificate.
Also be aware that wcf usually requires that an CRL is attached to the certificate. But this can also be generated with certmgr.exe.