客户端证书身份验证WCF
所以我对证书完全迷茫了。我在网上搜索了很多关于这个问题的解决方案和教程,但没有找到任何能真正帮助我的。 我试图做的是对我的WCF客户机服务器应用程序进行服务器和客户机证书验证。应用程序托管在IIS上。 我希望它在我的开发计算机上(服务器是localhost)和测试中(im是客户端,服务器是windows服务器) 我现在的配置是: 客户:客户端证书身份验证WCF,wcf,iis,certificate,client-certificates,Wcf,Iis,Certificate,Client Certificates,所以我对证书完全迷茫了。我在网上搜索了很多关于这个问题的解决方案和教程,但没有找到任何能真正帮助我的。 我试图做的是对我的WCF客户机服务器应用程序进行服务器和客户机证书验证。应用程序托管在IIS上。 我希望它在我的开发计算机上(服务器是localhost)和测试中(im是客户端,服务器是windows服务器) 我现在的配置是: 客户: <behaviors> <endpointBehaviors> <behavior name="myBehaviorC
<behaviors>
<endpointBehaviors>
<behavior name="myBehaviorConfig">
<clientCredentials>
<clientCertificate findValue="CN=MyTestClientCertificate"
storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName"/>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="MyBindingConfig">
<security mode="TransportWithMessageCredential">
<transport realm=""/>
<message clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost/Service.Calculator.svc"
binding="wsHttpBinding"
bindingConfiguration="MyBindingConfig"
behaviorConfiguration="MyBehaviorConfig"
contract="Service.ICalculator"
name="ICalculatorServiceEndpoint">
<identity>
<servicePrincipalName value="host"/>
</identity>
</endpoint>
</client>
服务器:
<behaviors>
<serviceBehaviors>
<behavior name="myBehavior">
<serviceCredentials>
<serviceCertificate findValue="CN=MyTestRootCA"
storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName"/>
<userNameAuthentication userNamePasswordValidationMode="Windows"/>
<clientCertificate>
<authentication certificateValidationMode="PeerOrChainTrust"/>
</clientCertificate>
</serviceCredentials>
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<unity operationContextEnabled="true"
instanceContextEnabled="true"
contextChannelEnabled="true"
serviceHostBaseEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="MyBinding">
<security mode="TransportWithMessageCredential">
<transport realm=""/>
<message clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="Service.Calculator"
behaviorConfiguration="myBehavior">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="MyBinding"
contract="Service.ICalculator" />
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange"
name="CalculatorServiceMex" />
</service>
</services>
“CN=MyTestRootCA”是“创建”证书的“权威”,我将其放在本地计算机上的受信任根证书以及本地计算机上的个人目录中。
它是客户端证书“CN=MyTestClientCertificate”的颁发者
没什么
我知道客户端证书应该在“MMC”的CurretUser目录中,但当它在那里时,我有一个例外,应用程序找不到证书。
我试着通过“FindBysubjectDiscrimitedName”和“FindByThumbprint”来定位它,两次都是相同的异常“找不到具有给定条件的证书…”,所以我将它放在本地机器中,并对其进行罚款。
有人知道它为什么不起作用吗
我在这方面遇到了很多问题和例外情况=\当前的问题是:
“X.509证书中未提供私钥”
有谁熟悉这个异常并知道如何修复它
非常感谢您的回答,我已经讨论了几天了您的配置文件没有指定clientCertificate storeLocation值,因此客户端证书需要位于LocalMachine store中,这是storeLocation的默认值 考虑以下示例,从中设置客户端证书存储位置:
<clientCertificate>
<certificate
findValue="www.cohowinery.com"
storeLocation="CurrentUser"
storeName="TrustedPeople"
x509FindType="FindByIssuerName" />
<authentication …
我确实在客户端配置中指定了客户端证书的存储位置。您建议的代码应该在服务器配置中?如果是这样,我应该指定什么证书,客户端证书位于客户端的计算机上。关于第二个错误,我确实有一个私钥,我用它来创建客户机证书,但仅此而已。我需要用它做些别的事情吗?比如把它放在一个特定的位置或者把它添加到配置中?