I\'m using Volley in Android to perform my app requests. Unfortunately, I\'m getting the following error:
com.android.volley.NoConnectionError: javax.net.ssl.SSL
After our comments maybe this can help you:
Your requestQueue
:
static {
requestQueue = Volley.newRequestQueue(Application.getContext(), new HurlStack(null, ClientSSLSocketFactory.getSocketFactory()));
}
The ClientSSLSocketFactory
:
public class ClientSSLSocketFactory extends SSLCertificateSocketFactory {
private SSLContext sslContext;
public static SSLSocketFactory getSocketFactory(){
try
{
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;
}
};
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[] { tm }, null);
SSLSocketFactory ssf = ClientSSLSocketFactory.getDefault(10000, new SSLSessionCache(Application.getInstance()));
return ssf;
} catch (Exception ex) {
return null;
}
}
@Override
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
}
@Override
public Socket createSocket() throws IOException {
return sslContext.getSocketFactory().createSocket();
}
}