Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.11.1

* Enable TLSv1.1 & TLSv1.2 for API 19 and below.

## 0.11.0

* Added option to set the video playback speed on the video controller.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package io.flutter.plugins.videoplayer;

import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;

public class CustomSSLSocketFactory extends SSLSocketFactory {
private SSLSocketFactory sslSocketFactory;

public CustomSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException {
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, null, null);
sslSocketFactory = context.getSocketFactory();
}

@Override
public String[] getDefaultCipherSuites() {
return sslSocketFactory.getDefaultCipherSuites();
}

@Override
public String[] getSupportedCipherSuites() {
return sslSocketFactory.getSupportedCipherSuites();
}

@Override
public Socket createSocket() throws IOException {
return enableProtocols(sslSocketFactory.createSocket());
}

@Override
public Socket createSocket(Socket s, String host, int port, boolean autoClose)
throws IOException {
return enableProtocols(sslSocketFactory.createSocket(s, host, port, autoClose));
}

@Override
public Socket createSocket(String host, int port) throws IOException {
return enableProtocols(sslSocketFactory.createSocket(host, port));
}

@Override
public Socket createSocket(String host, int port, InetAddress localHost, int localPort)
throws IOException {
return enableProtocols(sslSocketFactory.createSocket(host, port, localHost, localPort));
}

@Override
public Socket createSocket(InetAddress host, int port) throws IOException {
return enableProtocols(sslSocketFactory.createSocket(host, port));
}

@Override
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
throws IOException {
return enableProtocols(sslSocketFactory.createSocket(address, port, localAddress, localPort));
}

private Socket enableProtocols(Socket socket) {
if (socket instanceof SSLSocket) {
((SSLSocket) socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2"});
}
return socket;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package io.flutter.plugins.videoplayer;

import android.content.Context;
import android.os.Build;
import android.util.Log;
import android.util.LongSparseArray;
import io.flutter.embedding.engine.loader.FlutterLoader;
Expand All @@ -20,6 +21,9 @@
import io.flutter.plugins.videoplayer.Messages.VideoPlayerApi;
import io.flutter.plugins.videoplayer.Messages.VolumeMessage;
import io.flutter.view.TextureRegistry;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.HttpsURLConnection;

/** Android platform implementation of the VideoPlayerPlugin. */
public class VideoPlayerPlugin implements FlutterPlugin, VideoPlayerApi {
Expand Down Expand Up @@ -56,6 +60,19 @@ public static void registerWith(io.flutter.plugin.common.PluginRegistry.Registra

@Override
public void onAttachedToEngine(FlutterPluginBinding binding) {
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
try {
HttpsURLConnection.setDefaultSSLSocketFactory(new CustomSSLSocketFactory());
} catch (KeyManagementException | NoSuchAlgorithmException e) {
Log.w(
TAG,
"Failed to enable TLSv1.1 and TLSv1.2 Protocols for API level 19 and below.\n"
+ "For more information about Socket Security, please consult the following link:\n"
+ "https://developer.android.com/reference/javax/net/ssl/SSLSocket",
e);
}
}

@SuppressWarnings("deprecation")
final FlutterLoader flutterLoader = FlutterLoader.getInstance();
this.flutterState =
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Flutter plugin for displaying inline video with other Flutter
# 0.10.y+z is compatible with 1.0.0, if you land a breaking change bump
# the version to 2.0.0.
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
version: 0.11.0
version: 0.11.1
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player

flutter:
Expand Down