【发布时间】:2012-06-18 00:57:51
【问题描述】:
以下是我在服务器 web.config 文件中的配置设置,该文件是 WCF 应用程序。这里我使用 makecert.exe 创建 X509 证书。
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType= "WcfService1.CCustomValidatorClass,WcfService1"/>
<serviceCertificate
findValue="CN=SignedByCA1"
x509FindType="FindBySubjectDistinguishedName"
storeLocation="CurrentUser"
storeName="My" />
</serviceCredentials>
"CN=SignedByCA1" 是私钥,现在,我想从客户端调用 WCF 服务上的 Web 方法。 但是我需要从客户端设置 SetDefaultCertificate,请您帮忙我如何获取访问私钥 X509 证书的密钥。
ServiceReference1.Service1Client obj = new ServiceReference1.Service1Client();
obj.ClientCredentials.UserName.UserName = "Sukesh";
obj.ClientCredentials.UserName.Password = "Sukesh";
obj.ClientCredentials.ServiceCertificate.SetDefaultCertificate(
System.Security.Cryptography.X509Certificates.StoreLocation.CurrentUser,
System.Security.Cryptography.X509Certificates.StoreName.My,
System.Security.Cryptography.X509Certificates.X509FindType.FindBySubjectDistinguishedName,
"XYZ");
string str = obj.GetData(1); // web method
请帮帮我...
错误:{“X.509 证书 CN=SignedByCA1 链构建失败。使用的证书具有无法验证的信任链。更换证书或更改 certificateValidationMode。吊销功能无法检查吊销证书。\r\n"}
谢谢, 苏克什。
【问题讨论】:
标签: wcf