【发布时间】:2010-12-03 07:11:38
【问题描述】:
我正在编写一个使用公共 Web 服务的系统。我正在使用 VS2008 和经典的 .NET Framework 2.0 Web 服务技术使用 Web 服务。我的问题是没有使用 Web 服务或调用它的操作。
问题是当我从已签名的操作中获取响应时,生成的代理在幕后开始验证签名。那时我收到 WSE3003 错误。我(想我)已将服务证书加载到我的 LocalComputer/TrustedPeople 证书存储中,当我查看它的证书路径时,我可以看到一切正常:
威瑞信 3 类公共主要 CA
www.verisign.com/CPS Incorp.by Ref. LIABILITY LTD.(c)97...
servcert.there.com
但我不断收到以下异常:
Microsoft.Web.Services3.ResponseProcessingException: WSE910:在执行过程中发生错误 处理响应消息,以及 你可以在内部找到错误 例外。您还可以找到 响应中的响应消息 财产。 ---> Microsoft.Web.Services3.Security.SecurityFault: 安全令牌不能 认证或授权---> System.Security.SecurityException: WSE3003:证书的信任链 无法验证。请检查 如果证书已正确 安装在受信任的人中 证书存储。或者你可能想要 设置 allowTestRoot 配置 如果这是一个测试,则部分为 true 证书。
以下代码可能无法编译,并且我已经删除了一些敏感内容,但这里是我的工作背后的想法:
// Construct the wse proxy
MyServiceWse wsClient = new MyServiceWse();
// Assign the credentials
UsernameToken userToken = new UsernameToken("user", "pass", PasswordOption.SendPlainText);
wsClient.SetClientCredential(userToken);
wsClient.RequestSoapContext.IdentityToken = userToken;
// Find the client and service certificates
X509Certificate2 clientCert = MyCertificateManager.FindCertificate(StoreLocation.LocalMachine, StoreName.TrustedPeople, "mycert.here.com");
X509Certificate2 serviceCert = MyCertificateManager.FindCertificate(StoreLocation.LocalMachine, StoreName.TrustedPeople, "servicecert.there.com");
// Add the policy to the proxy
Policy policy = new Policy();
MySecurityClientAssertion assertion = new MySecurityClientAssertion();
assertion.SetServiceCertificate(serviceCert);
assertion.SetClientCertificate(clientCert);
policy.Assertions.Add(assertion);
wsClient.SetPolicy(policy);
// Assign the service URL and call an operation
wsClient.Url = "https://services.there.com/TheirService.asmx";
TheirOperationResponse r = wsClient.CallTheirOperation();
我当然希望我的代码是错误的,因为我比证书存储和信任链的东西更能理解它。任何帮助都会很棒。感谢您的努力。
【问题讨论】:
标签: c# .net ssl-certificate certificate