Amit
Amit

Reputation: 4000

secure socket communication in android

I am trying to setup secure socket communication to a server. I have successfully tried the Socket class, but that is not a secure way of communication. From what I gather, SSLSocketFactory and SSLSocket is required for securing communication via sockets. How do i go about implementing these?

I used this code

SSLSocketFactory s = new SSLSocketFactory();
socket = s.createSocket(url, port);

but eclipse says i cannot instantiate SSLSocketFactory.

Upvotes: 2

Views: 5317

Answers (1)

stork
stork

Reputation: 420

You need to call SSLSocketFactory.getDefault() to get an SSLSocketFactory instance.

Also, maybe this will be of use to you: Using client/server certificates for two way authentication SSL socket on Android

Upvotes: 4

Related Questions