0
votes

I have a rest webservice, which is being called by a java program. the rest service providers have given us a jwt token. and when i test this same in chrome (swagger) or postman client, it works fine. When i try to call it from java (webclient).the program throws an error:

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

this is how it is called:

     Response response = WebClient.create("url")
    .accept(MediaType.TEXT_PLAIN).header(HttpHeaders.AUTHORIZATION, "Bearer "+ <jwt token>).header(HttpHeaders.CONTENT_TYPE, "application/json").get();

Have anybody faced this ?

1
Check if this works for you Spring 5 WebClient using sslDusayanta Prasad
thanks @DusayantaPrasad, but in production what can be done ? any idea ? i dont want to use that flag in prodParameswar

1 Answers

2
votes

Java can't verify the certificates authenticaity. This can happen when self-signed certificates are used, but not only. When accessing from Chrome did you have to accept an untrusted certificate?

If the certificate is fine and you really trust it, you can have a look for example at this article to learn how to add a certificate to a trust store.