JMira
JMira

Reputation: 888

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/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.)

Upvotes: 2

Views: 3417

Answers (2)

Mike Mytkowski
Mike Mytkowski

Reputation: 596

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.

Upvotes: 2

adrianboimvaser
adrianboimvaser

Reputation: 2633

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

Upvotes: 0

Related Questions