I\'m trying my to create TLS v1.2 communication between a server and android client. I established a TLS v1.0 connection with any problem, but I cannot get v1.2. This is server
Kind of late to be answering this, but maybe someone else will need an answer.
I have run into the same issue. No matter whether you provide TLSv1.2 to the SSLContext.init()
method, some Android versions that I've tried do not enable TLS 1.2. You must enable that on your client socket using setEnabledProtocols()
just as you do for your server socket. For me, I did this in a custom SSLSocketFactory
I created:
public class MySSLSocketFactory extends SSLSocketFactory
throws NoSuchAlgorithmException {
private SSLContext mSSLContext;
public MySSLSocketFactory(KeyManager km) {
...
mSSLContext = SSLContext.getInstance("TLSv1.2");
...
mSSLContext.init(new KeyManager[] {km}, null, null);
...
}
@Override
public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
throws IOException {
SSLSocket s = (SSLSocket)mSSLContext.getSocketFactory().createSocket(socket, host, port, autoClose);
s.setEnabledProtocols(new String[] {"TLSv1.2"} );
return s;
}
...
}