使用证书调用 Web 服务
我正在尝试从 .NET 连接到 Web 服务。我正在引用班级图书馆中的服务。
我尝试将证书(即 .p12)导入以下位置
- 本地计算机\个人\证书
- 本地计算机\受信任的根证书\证书
- 当前用户\个人\证书
- 当前用户\受信任的根证书\证书
在我的网站中。我有以下内容来设置证书,但我不断从网络服务返回异常,表示没有证书。
<clientCredentials>
<clientCertificate findValue="[email protected]" storeName="My" storeLocation="LocalMachine" x509FindType="FindByIssuerName"/>
</clientCredentials>
如果需要更多代码,请告诉我。
谢谢
I'm trying to connect to a Web Service from .NET. I am referencing the service in my class library.
I've tried importing the certificate (which is a .p12) into the following places
- Local Computer\Personal\Certificates
- Local Computer\Trusted Root Certificates\Certificates
- Current User\Personal\Certificates
- Current User\Trusted Root Certificates\Certificates
In my Web.config I have the following to set the certificate, but I keep getting an exception back from the web service that says there's no cert.
<clientCredentials>
<clientCertificate findValue="[email protected]" storeName="My" storeLocation="LocalMachine" x509FindType="FindByIssuerName"/>
</clientCredentials>
If more code is needed, please let me know.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题可能是运行 IIS 的用户无权访问密钥库中的私钥。当我过去遇到这个问题时,我得到了一个令人费解的“未找到”异常,而实际上它确实是“权限被拒绝”。
您可以使用一个工具来授予用户访问您的密钥库的权限。您可以在此处获取该工具并阅读相关信息:http://msdn.microsoft.com/en-us/library/windows/desktop/aa384088(v=vs.85).aspx
I think the problem might be that the user IIS is running under doesn't have permissions to the private key in your keystore. When I had this problem in the past, I got a puzzling "not found" exception, when it really was "permission denied."
There is a tool you can use to grant a user permission to access your keystore. You can get the tool and read about it here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa384088(v=vs.85).aspx