WCF客户端只有在用IE访问URL后才能工作

发布于 2024-12-08 10:51:13 字数 410 浏览 5 评论 0原文

我们有一个 wcf 客户端,它调用外部 Web 服务。通过 SSL 访问该服务。该证书不是自签名证书。它由威瑞信颁发。

客户端托管在 IIS 6 中,应用程序池的身份是域服务用户。

每次我们希望我们的客户端访问远程服务时,我们都会遇到以下众所周知的异常:“无法为具有权限的 SSL/TLS 安全通道建立信任关系 -..”

事实证明,一旦您使用 IE 访问该 URL在同一台服务器上,我们的 WCF 客户端按预期工作并且证书被接受!

我的结论是,使用 IE 访问的 URL 在某种程度上修改了服务器,以便我们的 WCF 客户端能够随后进行验证。我们的 WCF 客户端缺少什么?

(我知道可以通过在 ServerCertificateValidationCallback 中返回 true 来规避证书验证,但这不是生产的选项。)

We have a wcf client, which calls an external webservice. The service is accessed over SSL. The certificate is not a self signed cert. It is issued by Verisign.

The client is hosted in IIS 6 and the application pool's identity is a domain service user.

Every time we want our client to access the remote service we get the following well known exception: "Could not establish trust relationship for the SSL/TLS secure channel with authority-.."

It turned out, that once you access the URL with IE on the same server, our WCF client is working as expected and the certificate is accepted!

My conclusion is, that the URL accessed with IE modified the server in a way, that our WCF client is able to do the validation afterwards. What is our WCF client missing?

(I'm aware that one can circumvent certificate validation by returning true in the ServerCertificateValidationCallback, but this is not an option for production.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

木有鱼丸 2024-12-15 10:51:13

考虑到所描述的情况,我怀疑您的 IIS 托管客户端无法加载 Verisign 根证书。我总是有点不清楚这样的基于 IIS 的客户端正在尝试使用哪个帐户访问证书存储。它可能是您的域服务帐户用户,可能是 ASP.NET 用户,也可能是其他系统定义的帐户。这经常会导致错误。

当您使用 IE 浏览服务时,毫无疑问用户(您自己的凭据)能够加载 Verisign 根证书并正确解析信任关系。

请:

  1. 确保 Verisign 根证书位于本地计算机帐户下的受信任根授权存储中
  2. 让客户端的 app.config 引用要从正确存储加载的正确根证书。
  3. 您可能需要运行 ProcessMonitor 来找出哪个用户正在尝试从存储区加载证书。

Considering the situation as described, I suspect that your IIS hosted client is not able to load the Verisign root certificate. And it is always a bit unclear to me under which account such IIS based client is trying to access the certificate store. It might be your domain service account user, it might be the ASP.NET user, it might be some other system defined account. This often causing the error.

When you browse the service with IE, there is no doubt about the user (your own credentials) being able to load the Verisign root certificate and resolve the trust relationship correctly.

Please:

  1. Make sure the Verisign root certificate in in the Trusted Root Authorities store under the Local Computer Account
  2. Have your app.config of your client refer to the correct root certificate to be loaded from the correct store.
  3. You might want to run ProcessMonitor to find out which user is trying to load the certificate from the store.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文