在java中使用SSL调用WS
我使用此客户端连接到一个运行良好的 Web 服务:
WSCSI WSCS = new WSCSI("http://localhost:8080/ServiceV2/services/WSCSISoap?wsdl","WSCSI","WSCSISoap");
IScoring instance = new ScoringCFA(WSCS);
assertEquals(true, instance.statusService());
我需要使用 SSL,所以我将 url 更改为: https://localhost:8181/ServiceV2/services/WSCSISoap?wsdl
并将其添加到VM 选项:(
-Djavax.net.ssl.trustStore="C:\cacerts.jks"
'Keytool -list -keystore "C:\cacerts.jks',当我运行此命令时,我看到我需要的证书就在那里)
当我运行客户端时出现此错误:
java.security.cert.CertificateException: No name matching localhost found.)
I connect to a web service with this client that work fine:
WSCSI WSCS = new WSCSI("http://localhost:8080/ServiceV2/services/WSCSISoap?wsdl","WSCSI","WSCSISoap");
IScoring instance = new ScoringCFA(WSCS);
assertEquals(true, instance.statusService());
I need to use SSL, So i change the url to:
https://localhost:8181/ServiceV2/services/WSCSISoap?wsdl
And add this in the VM Options:
-Djavax.net.ssl.trustStore="C:\cacerts.jks"
('Keytool -list -keystore "C:\cacerts.jks', when i run this command i see that the certificate that i need is there)
When i run the client get this error:
java.security.cert.CertificateException: No name matching localhost found.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能是因为您使用的证书是针对特定主机名 (www.myhost.com) 颁发的。尝试此解决方案 文章。
但请注意,代码示例仅用于本地主机测试,一旦您在适当的服务器上进行集成/组装测试,请将其删除。
That's probably because the cert you're using is issued against a specific hostname (www.myhost.com). Try the solution in this article.
But be warned, the code sample is only intended for localhost testing, remove it once you move onto the integration/assembly testing on a proper server.
在我看来,禁用 SSL 主机名验证可能对你有用。 这里是另一个示例。
Sounds to me that disabling SSL hostname verification might work for you. Another example here.