I'm trying to perform a http request. However, at the time of execution arises oshiyuka below. I suppose that it is impossible to create SSLContentFactory due to problems with the certificate. Who has ever seen such a thing?. JRE 1.5
Loaded class org.apache.http.conn.scheme.LayeredSchemeSocketFactory
Loaded class org.apache.http.conn.scheme.SocketFactory
Loaded class org.apache.http.conn.scheme.LayeredSocketFactory
Loaded class org.apache.http.conn.ssl.SSLSocketFactory
Loaded class org.apache.http.conn.ConnectTimeoutException
Loaded class org.apache.http.conn.ssl.X509HostnameVerifier
Loaded class org.apache.http.conn.ssl.AbstractVerifier
Loaded class org.apache.http.conn.ssl.AllowAllHostnameVerifier
Loaded class org.apache.http.conn.ssl.BrowserCompatHostnameVerifier
Loaded class org.apache.http.conn.ssl.StrictHostnameVerifier
Loaded class org.apache.http.impl.conn.SchemeRegistryFactory
Loaded class org.apache.http.conn.scheme.SchemeRegistry
Loaded class org.apache.http.conn.scheme.Scheme
Loaded class org.apache.http.conn.scheme.PlainSocketFactory
*** START APPLICATION TRACE ***
Defaultjava.lang.IllegalStateException: Failure initializing default SSL context
*** END APPLICATION TRACE ***
Listing:
private static DefaultHttpClient createHttpClient()
throws NoSuchAlgorithmException, KeyManagementException {
DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
defaultHttpClient.getParams().setParameter(
ConnRoutePNames.DEFAULT_PROXY, proxy);
defaultHttpClient = makeTrustfulHttpClient(defaultHttpClient);
defaultHttpClient.addRequestInterceptor(
new DiadocPreemptiveAuthRequestInterceptor(), 0);
return defaultHttpClient;
}
private static DefaultHttpClient makeTrustfulHttpClient(HttpClient base)
throws NoSuchAlgorithmException, KeyManagementException {
SSLSocketFactory ssf = getTrustfulSslSocketFactory();
ClientConnectionManager ccm = base.getConnectionManager();
ccm.getSchemeRegistry().register(new Scheme("https", 443, ssf));
return new DefaultHttpClient(ccm, base.getParams());
}
private static SSLSocketFactory getTrustfulSslSocketFactory()
throws NoSuchAlgorithmException, KeyManagementException {
SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] xcs, String string)
throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] xcs, String string)
throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
ctx.init(null, new TrustManager[] { tm }, null);
return new SSLSocketFactory(ctx,
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
}