How to encrypt data using SSL in Android? -
in app, need create registration form username , password combination.but needs go server encrypted.could please let me know if can use ssl , if yes, how use it?
thank you.
i'm making guess, if want actual handshake occur, have let android know of certificate. if want accept no matter what, use pseudo-code need apache http client:
schemeregistry schemeregistry = new schemeregistry (); schemeregistry.register (new scheme ("http", plainsocketfactory.getsocketfactory (), 80)); schemeregistry.register (new scheme ("https", new customsslsocketfactory (), 443)); threadsafeclientconnmanager cm = new threadsafeclientconnmanager ( params, schemeregistry); return new defaulthttpclient (cm, params); } // customsslsocketfactory: public class customsslsocketfactory extends org.apache.http.conn.ssl.sslsocketfactory { private sslsocketfactory factory = httpsurlconnection.getdefaultsslsocketfactory (); public customsslsocketfactory () { super(null); try { sslcontext context = sslcontext.getinstance ("tls"); trustmanager[] tm = new trustmanager[] { new fullx509trustmanager () }; context.init (null, tm, new securerandom ()); factory = context.getsocketfactory (); } catch (exception e) { e.printstacktrace(); } } public socket createsocket() throws ioexception { return factory.createsocket(); } // todo: add other methods createsocket() , getdefaultciphersuites(). // hint: make call member factory } //fullx509trustmanager class implements javax.net.ssl.x509trustmanager, yet none of methods perform work, sample here.
Comments
Post a Comment