开发者

Calling WS with SSL in java

I connect to a web service with this client that work fine:

WSCSI WSCS = new WSCSI("http://localhost:8080/Ser开发者_运维技巧viceV2/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.)


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.


Sounds to me that disabling SSL hostname verification might work for you. Another example here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜