码迷,mamicode.com
首页 > 其他好文 > 详细

WCF 添加X509证书加密

时间:2020-05-29 16:23:23      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:get   entity   service   name   value   证书   find   为我   ida   

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证书加密

标签:get   entity   service   name   value   证书   find   为我   ida   

原文地址:https://www.cnblogs.com/renfeng/p/12988031.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!