Showing posts with label java rest client over HTTPS. Show all posts
Showing posts with label java rest client over HTTPS. Show all posts

Saturday, 10 November 2018

Configuration of JAVA Rest client to work over HTTPS or SSL secured connection successfully



JAVA Rest Client over SSL : 


1. If jvm does not have the certificate installed of the server on which secured service is installed, then  we get following error :
 
com.sun.jersey.api.client.ClientHandlerException: 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 targetD.
 
2. Use portecle-1.11 software to install the certificate in the cacerts of the JVM or we can use java keytool as well.

3. Check the DNS name in the certificate to be installed.
 
4. Once certificate is installed in the keystore ( cacerts ) of jvm, then we must need to map certificate's DNS with the IP address of the service in the HOST file, otherwise we will get following error ( SSLHandshakeException ) :
 
   No subject alternative names matching IP address <ip-address> found.
 
5. Once entry done for the ip address to the DNS in the host file then we must need to use host name (DNS) while calling service.

   eg. https://sanjay.company.com:8443/service/resource.
 
 
***************************** HAPPY CODING **********************************