WCF未互访公钥仍调用成功?带证书客户端调用为何正常?
Your Practical Scenario Breakdown
Your setup—using authority-issued server/client certificates and seeing successful calls with that simple client code—perfectly demonstrates the above mechanics:
- Your server's WCF config includes
serviceCredentialssettings pointing to the issued server certificate. WCF loads it automatically, uses its private key for decryption, and shares its public key during the handshake. - Your client's config specifies the client certificate, and since the server's cert comes from a trusted authority, the client's trust store validates it without extra work.
- The line
new ServiceClient.Service1Client()pulls all binding and certificate config, triggering the automatic handshake and encryption flow. That's why yourAdd(1,1)call works seamlessly with zero public key handling in your code.
A couple of quick notes to reinforce this:
- If you were using self-signed certificates, you'd have to manually import them into each machine's Trusted Root Certification Authorities store to get the same result—self-signed certs don't have a trusted root chain by default.
- Ensure both certificates have accessible private keys: when importing the
.pfxfiles, you need to allow private key access so WCF can use them for decryption and signing.
内容的提问来源于stack exchange,提问作者Jason
相关产品推荐
相关产品推荐

