problems with SSL. I tested the SSL communication between my server
and a java client at it works without problems, and now im having
problems trying to code an android client.
I imported my truststore on res/raw folder and so on, but the main
problem (even if i read the API) is that I dont know how to create the
sockets to comunicate with the server using that keystore. For example
I tried this:
InputStream mIS =
context.getResources().openRawResource(R.raw.truststoreclient);
keyStore = KeyStore.getInstance("BKS");
keyStore.load(mIS, "aquabona".toCharArray());
mKMF = KeyManagerFactory.getInstance("X509");
mKMF.init(keyStore,
"truststoreclient".toCharArray());
KeyManager[] mKM = mKMF.getKeyManagers();
SSLContext sc = SSLContext.getInstance("TLS");
TrustManagerFactory tmf =
TrustManagerFactory.getInstance("X509");
tmf.init(keyStore);
sc.init(mKM, tmf.getTrustManagers(), new
java.security.SecureRandom());
SSLSocketFactory sslsocketfactory = new
SSLSocketFactory(keyStore);
//Si hacemos la consulta a un unico servidor
if (ips.size() < 2 && ipPorts.size() < 2) {
String singleServer = ips.get(0);
int singlePort = Integer.parseInt(ipPorts.get(0));
Socket soc = sslsocketfactory.createSocket();
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params,
HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, "utf-8");
params.setBooleanParameter("http.protocol.expect-
continue", false);
Socket socket = sslsocketfactory.connectSocket(soc,
singleServer, singlePort, null, 0, params);
And now im having problems with certificates...
So is there an easier way to code up a SSL socket implementation on
android that uses that keystore?
Post some code, examples or ideas please.
Thanks all.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment