在使用 Web 服务的客户端应用程序中使用证书
我正在实现一个使用 Web 服务的 VB.NET 桌面应用程序。
Web 服务是用 Java 实现的,我目前在本地主机上使用 Tomcat 来托管 Web 服务。
Web 服务需要与客户端进行安全通信,因此我遵循了概述如何使用 Java 的 keytool.exe 创建两个 .jks 密钥库(一个用于客户端,一个用于服务器)的说明,然后创建两个 .cer 证书(一个一个用于客户端,一个用于服务器)
我已将生成的密钥库和证书放入 Web 服务期望它们的目录中(根据说明)
我已将证书安装到 TrustedPeople 中,并尝试通过设置来使用该证书ClientCredentials.ClientCertificates 属性如下:
myServiceProxy.ClientCredentials.ClientCertificate.SetCertificate(storeLocation.CurrentUser, StoreName.TrustedPeople, X509FindType.FindByIssuerName, "name")
当我尝试调用任何方法时,我不断收到以下错误消息:
在处理
我的问题是我不知道如何在使用 Web 服务的 VB.NET 客户端应用程序中使用它。我这样做可能完全错误。任何有关此主题的指导将不胜感激。
谢谢你,
-弗林尼
I am implementing a VB.NET desktop application which consumes a web service.
The web service implemented in Java and I currently using Tomcat on my localhost to host the web service.
The web service requires secure communication with the client and so I have followed instructions that outlined how to use Java's keytool.exe to create two .jks keystores (one for the client and one for the server) and then create two .cer certificates (one for the client and one for the server)
I have placed the keystores and certificates generate into the directory where the web service is expecting them (according to the instructions)
I have installed the certificates into TrustedPeople and have attempted to use the certificate by setting the ClientCredentials.ClientCertificates property like this:
myServiceProxy.ClientCredentials.ClientCertificate.SetCertificate(storeLocation.CurrentUser, StoreName.TrustedPeople, X509FindType.FindByIssuerName, "name")
I keep getting the following error message when I try to call any method:
An error was discovered processing the <wsse:Security> header
My problem is that I don't know how to use this in the VB.NET client application that is consuming the web service. I could be doing this completely wrong. Any guidance on this topic would be greatly appreciated.
Thank you,
-Frinny
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然我已经 10 年没有编写 VB 代码了,但这应该可以帮助您入门:http:// /www.example-code.com/vbdotnet/ssl_client_certificate.asp
特别是这看起来像是正在加载包含证书的文件:
certStore.LoadPfxFile("chilkat_secret.pfx","secret")
这会提取证书并将其用于连接:
While I haven't coded VB for 10 years, this should get you started: http://www.example-code.com/vbdotnet/ssl_client_certificate.asp
especially this looks like it is loading the file containing the certificate:
certStore.LoadPfxFile("chilkat_secret.pfx","secret")
and this extracts the certificate and uses it for the connection:
当我必须使用证书和 WS 时,我也遇到了很多问题。 使用证书 MMC 并验证:
X509FindType.FindByIssuerName, "name"
查找证书,打开证书,确保颁发者名称匹配(我猜不是,因为它看起来像是从示例中复制和粘贴)。如果所有这些都失败,请尝试尝试证书位置(我隐约记得能够使用一个位置的证书而不是另一个位置的证书的一些问题)以及用于搜索证书的属性。
另外,既然你问了有关证书的问题,我就回答了有关证书的问题。最好检查是否存在内部异常并查看 - 这可能是另一个问题。
When I had to work with certificates and WS, I had lots of issues with the them too. Use the certificates MMC and verify:
X509FindType.FindByIssuerName, "name"
open the certificate, make sure the issuer name matches (I guess not since it seems like copy&paste from example).If all of this fails, try to experiment with the certificate location (I vaguely remember some issue with being able to use certificates from one location and not the other), and with the property you use to search for the certificates.
Plus, since you asked about certificates I answered about certificates. It's a good idea to check if there's an inner exception and see - it may be another problem.