我从这篇文章中了解到 JB 支持 TLSv1.2。现在我进退两难了,当我运行以下测试代码时。我得到支持的协议为 TLS1.0 而不是 TLSv1.2。做错什么了吗?
public class SSLTest extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ssltest);
SSLSocketFactory mSslSocketFactory = null;
SSLContext sslContext = null;
try {
sslContext = SSLContext.getInstance("Default");
} catch (NoSuchAlgorithmException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
mSslSocketFactory = sslContext.getSocketFactory();
SSLSocket sock = null;
try {
sock = (SSLSocket)mSslSocketFactory.createSocket();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String[] prots = sock.getEnabledProtocols();
for(int i=0;i<prots.length;i++){
Log.d("TEMP","$$$$$$$$$$$$$$$$$$$$$$$ ::: " + prots[i]);
}
SSLParameters sslp = sock.getSSLParameters();
String[] newprots = sslp.getProtocols();
for(int i=0;i<newprots.length;i++){
Log.d("TEMP","$$$$$$$$$$$$$$$$$$$$$$$ ::: " + newprots[i]);
}
}
输出:
10-11 11:57:53.280: D/TEMP(7928): $$$$$$$$$$$$$$$$$$$$$$$ ::: SSLv3
10-11 11:57:53.280: D/TEMP(7928): $$$$$$$$$$$$$$$$$$$$$$$ ::: TLSv1
10-11 11:57:53.280: D/TEMP(7928): $$$$$$$$$$$$$$$$$$$$$$$ ::: SSLv3
10-11 11:57:53.280: D/TEMP(7928): $$$$$$$$$$$$$$$$$$$$$$$ ::: TLSv1