2016-12-27 118 views
2

我使用的網站是https協議,因此我想使用忽略證書。但我無法設置忽略證書。jodd http client如何設置忽略證書

public class JoddHttpClientDemoApplication { 
    public static void main(String[] args) throws Exception { 
     SpringApplication.run(JoddHttpClientDemoApplication.class, args); 
     HttpRequest request = HttpRequest.get("https://xxxxx.com?0.6891255003788694"). 
      header("Referer","https://xxxxx.com/x.jsp"); 
     HttpResponse response = request.send(); 
     System.out.println(response); 
    } 
} 

我得到這樣的錯誤,

jodd.http.HttpException:sun.security.validator.ValidatorException:PKIX路徑建設失敗

+0

你可以添加完整的堆棧跟蹤嗎? – Thrasher

+0

我的回答有幫助嗎? – igr

+0

@игор\t 非常感謝你 – senz

回答

1

切換到最新Jodd V3 .8.1。在那裏你有以下方法:trustAllCerts。它會信任所有的證書:)使用它像這樣:

HttpRequest 
    .get("https://xxxxx.com?0.6891255003788694") 
    .header("Referer","https://xxxxx.com/x.jsp") 
    .trustAllCerts(true); 
+0

非常感謝。 – senz

+1

我可以刪除我的IgnoreCertificatesSocket.java – senz