Open dantheman213 opened 3 years ago
Stuff that's been tried:
@dantheman213
Can you provide flutter doctor -v
? Are you on Android or iOS ?
Hi @darshankawar, thanks for reviewing. The error that I am currently receiving is when I'm testing in Android emulator or on a real device. Here's the error again for visibility:
PlatformException: Video player had error com.google.android.exoplayer2.ExoPlaybackException: Source error
This is an Android error with the underlying Flutter VideoPlayer's native asset. Looks like ExoPlayer is being used for Android. I imagine iOS will have the same problem as it's typical for default HTTPS to give off a warning or have its default config to reject self signed certificates.
Here is a summary from flutter doctor -v
.
> flutter doctor -v
[✓] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.19042.804], locale en-US)
• Flutter version 1.22.6 at D:\flutter
• Framework revision 9b2d32b605 (3 weeks ago), 2021-01-22 14:36:39 -0800
• Engine revision 2f0af37152
• Dart version 2.10.5
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\danie\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[✓] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[✓] VS Code (version 1.53.2)
• VS Code at C:\Users\danie\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.16.0
[✓] Connected device (2 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.150
• Edge (web) • edge • web-javascript • Microsoft Edge 88.0.705.63
• No issues found!
I'm guessing the following files (along with the iOS counterpart) need to updated to have an option so you can configure the player to accept self signed certificates.
To see the issue for yourself, just take the sample code and use any self signed HTTPS asset instead of the HTTP asset provided in example.
https://github.com/flutter/plugins/tree/master/packages/video_player/video_player#example
Thanks @dantheman213 for the details. I am able to replicate the issue which seems to occur on Android. iOS plays the video properly.
Launching lib/main.dart on SM A260G in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Debug service listening on ws://127.0.0.1:52228/CsgS6FaEwDI=/ws
Syncing files to device SM A260G...
I/ExoPlayerImpl(11022): Init 1cfa707 [ExoPlayerLib/2.12.1] [a2corelte, SM-A260G, samsung, 27]
E/ExoPlayerImplInternal(11022): Playback error
E/ExoPlayerImplInternal(11022): UnknownHostException (no network)
E/flutter (11022): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: Source error, null, null)
E/flutter (11022):
Recent related but closed issues:
https://github.com/flutter/flutter/issues/68094 https://github.com/flutter/flutter/issues/72696
Thanks for the quick reply and your review @darshankawar.
Also, if iOS player works with no issues that may not be the ideal solution either. Self signed certificates SHOULD throw a warning but you should be able to configure the player to ignore it. Self signed SSL is more secure than HTTP but depending on how its deployed it has its own security issues as well. It should be up to the developer if they want to support self signed SSL certificates or not in their Flutter app.
Hmm, double checking myself I see in your screenshot you're using this URL:
https://www.sample-videos.com/video123/mp4/720/big_buck_bunny_720p_20mb.mp4
This URL is using a VALID signed SSL certificate. Please see here:
When I check in Chrome tools I see this error:
GET https://www.sample-videos.com/video123/mp4/720/big_buck_bunny_720p_20mb.mp4 net::ERR_CONNECTION_TIMED_OUT
Something else going on with this asset. You might want to try spinning up your own local nginx with a self signed SSL and some sample mp4 to test this out yourself.
What would be the next step? Any ballpark ETA for resolution available?
CustomSSLSocketFactory.java used only for enable TLSv1.1
& TLSv1.2
for API 19
and below.
For more information about security SSL: UnknownCa & SelfSigned
Caution: Many web sites describe a poor alternative solution which is to install a TrustManager that does nothing. If you do this you might as well not be encrypting your communication, because anyone can attack your users at a public Wi-Fi hotspot by using DNS tricks to send your users' traffic through a proxy of their own that pretends to be your server. The attacker can then record passwords and other personal data. This works because the attacker can generate a certificate and—without a TrustManager that actually validates that the certificate comes from a trusted source—your app could be talking to anyone. So don't do this, not even temporarily. You can always make your app trust the issuer of the server's certificate, so just do it.
Same issue here also. Trying to play https://www04.cloud9xx.com/videos/hls/PPiRAsdEQIc0l0gNOAkZCA/1613693393/137943/0d2d81bdc13b93efd22f3583a4b9c0f0/ep.37.1604050682.360.m3u8
Any idea when this issue would be resolved?
I am getting the same issue. Any solution yet?
hi @pratikbaid3 I also have the same issue, we resolved it by getting the proper CA Certificate and doing some Network security configuration in android folder, please check below link for Network security configuration https://developer.android.com/training/articles/security-config#CustomTrust
The VideoPlayer widget should support self signed SSL. There's plenty of use cases for not having a CA signed certificate.
@patthipati Thank you for the help so far, but wouldn't this mean that for each URL that we access, there would have to be a manual CA Certificate and Network Config?
Same error, couldn't play any video from network @darshankawar will there be any fix or way to workaround?
Any other package to play videos?
Nope, but it'd be great if the maintainers of this repo would fix this issue. hard to consider this a mature video plugin if it can't accept videos from self signed HTTPS URLs.
Hi Flutter team, any idea when this issue will be resolved? It's an issue on both iOS and Android and there's been no activity on this ticket for months now. Thanks.
Created a PR to help deal with this issue. iOS still needs to be implemented and there may be some minor things required. Maintainers, what's the next step to get this PR moved into master?
I am having the same problem.
Issue persists. Any ETA?
Is there any workaround? any other package?
Hi, I can reproduce this issue with my own self-signed certificates on the latest stable
and master
channel.
Any progress in this issue?
Up!
I still have this problem on ios. I tried using NSAppTransportSecurity in ios (https://developer.apple.com/news/?id=g9ejcf8y) similar to network-security-config in android (https://developer.android.com/privacy-and-security/security-config#TrustingAdditionalCas), but it didn't work. Is it possible to find a similar solution for ios which @patthipati suggested for android? Or can we set certificates in the ios native for all app and packages? In flutter, this can be achieved as follows:
final certificates = await rootBundle.load('public/assets/openssl/certificate.crt');
HttpOverrides.global = _AppHttpOverrides(certificates);
class _AppHttpOverrides extends HttpOverrides {
_AppHttpOverrides(this.certificates);
ByteData certificates;
@OverRide
HttpClient createHttpClient(SecurityContext? context) {
final securityContext = SecurityContext();
securityContext.setTrustedCertificatesBytes(certificates.buffer.asUint8List());
return super.createHttpClient(securityContext);
}
}
Steps to Reproduce
Expected results:
Actual results: