Home > Back-end >  HttpClient UnsupportedOperationException
HttpClient UnsupportedOperationException

Time:01-01

In launching the HTTPS request has the following processing
//set the HTTPS exemption certificate validation 
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));
{} the catch (KeyManagementException ex)
Throw new RuntimeException (ex);
{} the catch (NoSuchAlgorithmException ex)
Throw new RuntimeException (ex);
}
}


Now add new features to project the original this part of the code is not modified,
But now the original function in execution to the SchemeRegistry registry=CCM. GetSchemeRegistry (); In Java. Lang. UnsupportedOperationException
Abnormal information below
 Java. Lang. UnsupportedOperationException 
The at org. Apache. HTTP. Impl. Client. InternalHttpClient $1. GetSchemeRegistry (InternalHttpClient. Java: 239)
The at A.B.C.D.H ttpUtils. SslClient (HttpUtils. Java: 196)
The at A.B.C.D.H ttpUtils. DoPost (HttpUtils. Java: 105)


HttpClient version conflicts is to add a new jar package, lead to this problem? Or for other reasons? , every brother please give directions
  • Related