Ignore certification authentication on Axis client for WCF service - java

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

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.

Related

HTTPS vs HTTP in java

We got an wsdl from a website and we generated the java code with Axis2. Works perfect but the site is HTTPS and has the SSL certificatite turned off.
When I make a request I get
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
The admin from the site told me to disable SSL
I can't seem to find a solution for this.
What do I need to call before the request to disable this?

Automaticly resolve Java SSL errors? - Unable to find valid certification path to requested target

I'm trying to put together a simple web crawler using the jsoup library.
However when calling "Jsoup.connect(url).get()" On some sites I'm getting the error below.
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
There are a number of other questions about this error, but all of them suggest resolving it by manually creating a cert for the site in question. Since I'm trying to do a web crawler that will connect to many sites, that's not really a solution.
Is there a recommended way to resolve this? For a simple web crawler security is not particularly a concern, so the authenticity of the cert does not matter.
Solution I'm using for now, Option 2 mentioned in a related question here. Accept server's self-signed ssl certificate in Java client
You should ignore TSL validation, set validateTLSCertificates(false):
Document document = Jsoup.connect(url).timeout(10000).validateTLSCertificates(false).get();

How to find the missing certificate and add it?

I have a simple JAVA application which connects to HTTPS website and downloads a file from there. This JAVA application has been deployed to a Unix server in the form of a JAR file. When I run the JAR, I get 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
When I searched this exceotion on Google, I came to know that the solution is to add the missing certificate to the keystore. But the thing is, I do not know how to find that which certificate is missing. And after finding it , how to add it? Where to add it?
There are many posts on multiple websites for above exception, but I get stuck on how to know the missing certificate, the server-alias of the https server and many more questions. Can someone help me with the exact steps?
Thanks in advance...
Could you please open https site and in the left side of address bar you can see the lock sign (in Firefox). Click on it, then go to view certificate and then export it to some file. Now you have the certificate. The next step would be to add this certificate into your certificate store.
To import the certificate you can use java keytool command, please refer to this post http://www.planetlarg.net/support-cookbook/ssl-secure-sockets-layer/add-x509-certificate-java-keystore-using-keytool

Amazon: SSLHandshakeException happening intermittently

This is a difficult problem for me. The following shows the portion of the code that throws the exception when I try doing an Amazon search:
AWSECommerceServiceLocator locator = new AWSECommerceServiceLocator(fooConfig);
locator.setAWSECommerceServicePortEndpointAddress(SourceCountry.USA.getPortAddress());
//throws exception
AWSECommerceServicePortType type = locator.getAWSECommerceServicePort();
Heres the exception:
NativeException: bc.exceptions.FatalException:
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
The weird thing is that this happens intermittently. At times, everything works perfectly. Anybody have any ideas? At this point, any help is greatly appreciated.
Thanks.
There could be several root causes:
Outdated java installation which doesn't contain a valid root certificate for some of the Amazon servers
Invalid server-side certificate that is not trusted by any valid issuer
To debug to the console from the client side, add -Djavax.net.debug=all to the command line. The page on Debugging SSL/TLS connections may provide insight into the underlying error.

Axis over SSL and 2-way authentication with a PKCS#12 keystore

I have PKCS#12 keystore that I've sucessfully imported in my browser for accessing a server that needs 2-way SSL authentication. Works perfectly reaching any https URL there.
However, I'm unable to access an URL in the same server, and from the same host when using Axis 1.4. The given Axis faultString is:
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
My javax.net.ssl.{keyStore,keyStorePassword,keyStoreType} properties seem to be set up fine.
How can I resolve this?
I came across a simpler answer if all you want is for your client to be able to call the SSL web service and ignore SSL certificate errors. (Of course you would NOT do this in production!, but it sure is handy for testing.)
Just put this statement before you invoke any web services:
System.setProperty("axis.socketSecureFactory",
"org.apache.axis.components.net.SunFakeTrustSocketFactory");
I found this at the Axis wiki.
Finally, importing the certificates into my own truststore, using Andreas Sterbenz's InstallCert, and setting the trustStore properties as indicated here did the trick!

Categories

Resources