自托管 WCF 服务器 - 从文件而不是证书存储加载证书
我目前正在使用 wcf 服务器,希望从文件/资源而不是证书存储加载我的证书,以使部署更容易。有什么想法如何做到这一点?
感谢您的帮助!
I'm currently working on a wcf server and would like to load my certificate from a file/resource instead of the certificate store to make deployment easier. Any ideas how to do this?
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设您使用的是双工通道,您可以按如下方式从文件加载证书:
在您的客户端代码中,按照与上面相同的方式加载证书
我认为从这一点来看您应该没问题。请记住,如果从文件加载,则必须加载由 pvk2pfx.exe 生成的 .pfx 文件,它同时具有私钥和公钥。否则 WCF 将会对在哪里查找私钥感到困惑。
Suppose you are using duplex channel,you can load certificate from file as the following:
In your client's code, load the certificate as same as above
I think you should be okay from this point. Just remember that if you load from a file, you have to load the .pfx file which is generated by pvk2pfx.exe , it has both private key and public key. Otherwise WCF will get confused to where to lookup for private key.
我想这就是您正在寻找的:
http://www.codeproject.com/KB/WCF/wcfcertificates.aspx
I think this is what you are looking for:
http://www.codeproject.com/KB/WCF/wcfcertificates.aspx
以下SO问题有一个详细的代码示例,说明如何执行此操作,但是在证书受密码保护的情况下,这可能不起作用。
带有证书的编程式 WCF 消息安全
The following SO question has a detailed code sample of how to do this, however this may not work where the certificates are password-protected.
Programmatic WCF Message Security with Certificates