Ignore certification authentication on Axis client

2019-02-07 07:05发布

问题:

I created an axis client to WCF service (the client was generated by Eclipse, using the WSDL as an input).

The client works fine when using HTTP.

When using HTTPS I'm getting the following exception:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I understand the error, but I don't want to give it a place where the certificates are located.

I want to tell Axis to avoid this step (accept any certificate without checking it).

I know how to do it with HttpsURLConnection (create a custom validator which does nothing), but I don't know how to do it with axis... (How can I tell axis to use my custom validator, or better, how can I tell it to ignore this step at all).

Can someone help me?

Thanks,

Mattan

回答1:

I had the same problem and fixed it using:

AxisProperties.setProperty("axis.socketSecureFactory","org.apache.axis.components.net.SunFakeTrustSocketFactory");

In case this doesn't work, have a look here.