Skip to content
Advertisement

How should I consume rest web service with ssl

I am supposed to write client which must fetch data from web service. I am follow this guide: https://spring.io/guides/gs/consuming-rest/ The website has https. My code:

JavaScript

When I run my program I get this exception:

JavaScript

It seems like I need to enable ssl. Okay, I have follow few guides and they don’t really help me. One of them: https://snmaddula.bitbucket.io/enable-https-in-spring-boot-app/ I also tried to disable ssl(I did it in postman) it seems like some of solutions are outdated or I don’t get how to use them. Such an example is the best answer from this post: Disabling SSL Certificate Validation in Spring RestTemplate Please help me, I think my task must be very easy but this I have already spent a few hours trying to make this program work.

Advertisement

Answer

You need to add the certificate of the rest web service to the truststore file of the used JVM located at %JAVA_HOME%libsecuritycacerts.

For getting the certificate open the url you are calling in a chrome and download it. You can download the certificate by clicking on site information icon then details than copy to file as below: enter image description here

Afterwards open git bash by running it as administrator and run this command:

JavaScript

After adding it to the keystore you might want to restart the pc.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement