在 發起 https的請求 有如下處理
//設定https免證書驗證
private static void sslClient(HttpClient httpClient) {
try {
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] xcs, String str) {
}
public void checkServerTrusted(X509Certificate[] xcs, String str) {
}
};
ctx.init(null, new TrustManager[] { tm }, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
ClientConnectionManager ccm = httpClient.getConnectionManager();
SchemeRegistry registry = ccm.getSchemeRegistry();
registry.register(new Scheme("https", 443, ssf));
} catch (KeyManagementException ex) {
throw new RuntimeException(ex);
} catch (NoSuchAlgorithmException ex) {
throw new RuntimeException(ex);
}
}
現在給專案 加新功能 原這部分的代碼 沒有修改 ,
但現在 原功能 在執行到 SchemeRegistry registry = ccm.getSchemeRegistry(); 發生 java.lang.UnsupportedOperationException
例外資訊如下
java.lang.UnsupportedOperationException
at org.apache.http.impl.client.InternalHttpClient$1.getSchemeRegistry(InternalHttpClient.java:239)
at a.b.c.d.HttpUtils.sslClient(HttpUtils.java:196)
at a.b.c.d.HttpUtils.doPost(HttpUtils.java:105)
是添加新的jar包, 產生httpClient版本沖突 導致這個問題了嗎? 還是 別的什么原因? 請各位大佬指點一下
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/242968.html
標籤:Web 開發
上一篇:有沒有反編譯的高手,一起致富好嗎
下一篇:java檔案洗掉指定內容
