Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Unirest disable cerificate

May you tell me the way to disable certificate verify for using Unirest as rest client.

I use Unirest with Java Spring. Below is my source code:

try {
    HttpResponse<String> response = Unirest.post("myurl")
      .header("content-type", "application/json")
      .header("accept", "application/json")
      .body("my json data here")
      .asJson();
} catch (Exception e) {
    logger.info("==================REST CLIENT ERROR: "+e.getMessage());
}

The result:

==================REST CLIENT ERROR: 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

like image 574
munyso Avatar asked Jun 28 '26 14:06

munyso


1 Answers

I know this thread is very old but just writing in case somebody else is looking for simpler way.

Unirest has now inbuilt support for this.

Unirest.config().verifySsl(false);

This worked for me.

like image 68
Monu Avatar answered Jul 01 '26 02:07

Monu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!