Is there a java setting for disabling certificate validation?

前端 未结 7 1774
死守一世寂寞
死守一世寂寞 2020-12-01 02:08

I received this error while trying to start up an application:

Sun.security.validator.ValidatorException: PKIX path validation failed: 
java.security.cert.C         


        
7条回答
  •  遥遥无期
    2020-12-01 02:20

    It is very simple .In my opinion it is the best way for everyone

           Unirest.config().verifySsl(false);
           HttpResponse response = null;
           try {
               Gson gson = new Gson();
               response = Unirest.post("your_api_url")
                       .header("Authorization", "Basic " + "authkey")
                       .header("Content-Type", "application/json")
                       .body("request_body")
                       .asString();
               System.out.println("------RESPONSE -------"+ gson.toJson(response.getBody()));
           } catch (Exception e) {
               System.out.println("------RESPONSE ERROR--");
               e.printStackTrace();
           }
       }
    

提交回复
热议问题