WCF 添加X509证书加密
Posted renfeng
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WCF 添加X509证书加密相关的知识,希望对你有一定的参考价值。
1.先在服务器添加证书 makecert.exe -sr LocalMachine -ss My -a sha1 -n CN=TestServer -sky exchange -pe
2.设置证书的权限,everyone添加读取权限
3.服务器端配置
<security mode="Message"> <message clientCredentialType="Certificate" /> </security> <identity> <certificateReference storeName="My" x509FindType="FindBySubjectName" findValue="SkywindServer" /> </identity> <clientCertificate> <authentication certificateValidationMode="None" />这里设置成None因为我们创建的是不受信任的证书 </clientCertificate> <serviceBehaviors> <behavior name="BasicServiceBehavior"> <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" /> <serviceDebug includeExceptionDetailInFaults="false" /> <serviceCredentials> <clientCertificate> <authentication certificateValidationMode="None" /> </clientCertificate> <serviceCertificate findValue="SkywindServer" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" /> </serviceCredentials> </behavior> </serviceBehaviors>
4.客户端配置
<behaviors> <endpointBehaviors> <behavior name="CustomBehavior"> <clientCredentials> <!--客户端证书--> <clientCertificate findValue="Skywind" storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectName"/> <serviceCertificate> <authentication certificateValidationMode="None"/> </serviceCertificate> </clientCredentials> </behavior> </endpointBehaviors> </behaviors>
以上是关于WCF 添加X509证书加密的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 makecert 创建 WCF 接受的 X509 证书