亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將REST客戶端與標頭一起使用時獲取ssl.SSLHandshakeException

將REST客戶端與標頭一起使用時獲取ssl.SSLHandshakeException

慕田峪7331174 2021-05-14 14:42:57
我有一個外部REST資源,其中包含以下詳細信息:網址:( abc.com/orders域位于https)我需要將UserID作為HTTP頭傳遞,其鍵“ user”值為“ abcd”這將返回JSON響應我為此使用下面的Java代碼:try {            Client client = Client.create();            WebResource webResource = client.resource("abc.com/orders");            ClientResponse response = webResource.header("user", "abcd").accept("application/json")                    .get(ClientResponse.class);            if (response.getStatus() != 200) {                throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());            }            String output = response.getEntity(String.class);            System.out.println("Output from Server .... \n");            System.out.println(output);        } catch (Exception e) {            e.printStackTrace();        }但是我正在低于異常,盡管它可以正常工作 PostMancom.sun.jersey.api.client.ClientHandlerException: 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    at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:155)    at com.sun.jersey.api.client.Client.handle(Client.java:652)    at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)    at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)    at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:509)我嘗試對其進行搜索,發現需要從該URL獲取證書并將其添加到jdk/lib/security文件夾中的某個地方。但我不知道該如何進行。
查看完整描述

2 回答

?
BIG陽

TA貢獻1859條經驗 獲得超6個贊

男子!不需要以上任何內容?。?!只需RestAssured.useRelaxedHTTPSValidation();在Rest Api代碼之前通過即可。完成!


查看完整回答
反對 回復 2021-05-26
  • 2 回答
  • 0 關注
  • 178 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號