我的项目已经使用Android Volley网络框架很长一段时间了,但最近我发现了互联网上发布的SSL 3.0协议错误。
我想知道如何找出我的项目使用的TLS版本,以及如何确认库是否已更新。
这是我的源代码片段:
HttpStack stack = new HurlStack();
Network network = new BasicNetwork(stack);
mHttpRequestQueue = new RequestQueue(new NoCache(), network);
mHttpRequestQueue.start();
我认为重点在于HurlStack类,它取决于org.apache.http
包,但我无法弄清楚TLS / SSL配置的位置。
答案 0 :(得分:1)
在Android上,使用的TLS版本主要取决于使用的Android版本。 Apache Volley基于Apache Http Client,基于HttpsUrlConnection,因此使用标准的SSL / TLS SSLSocketFactory。
在Android 4.3以下通常只支持SSLv3和TLS 1.0。在以后的版本中,通常支持TLS 1.1和1.2但禁用。
从Android 5 TLS 1.1和TLS 1.2开始是supported and enabled by default
答案 1 :(得分:0)
@ w3bshark的回答对我有用。但之前使用该代码,请确保包含更新安全提供商的代码。在我的情况下,TLS在我更新安全提供程序之前不起作用。以下是更新它的代码。
private void updateAndroidSecurityProvider() {
try {
ProviderInstaller.installIfNeeded(this);
} catch (GooglePlayServicesRepairableException e) {
Log.e("Test321", "PlayServices not installed");
} catch (GooglePlayServicesNotAvailableException e) {
Log.e("Test321", "Google Play Services not available.");
}
}