Android : Android HttpClient libary that supports session management and ssl connections

on Monday, September 15, 2014


Hi i'm trying to connect to my server from my app but my server sets a session which i need to keep open but i also need to accept ssl certificate. Does anyone know the best way to do this or the best libray to handle this?


i have a function that makes network calls from an array the problem is the server requires the a login call to be made to start the session but every time i loop through the array it creates a new httpClient as i am running this code in that function and so ends the session and tries to start a new one but don't want to re login every time is there a way to store the session and accept certificates



HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;

DefaultHttpClient client = new DefaultHttpClient();

SchemeRegistry registry = new SchemeRegistry();
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
registry.register(new Scheme("https", socketFactory, 443));
SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());

// Set verifier
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);

0 comments:

Post a Comment